PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Noms de domaine > comp.protocols.tcp-ip > multiple TCIP connections
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.protocols.tcp-ip TCP and IP network protocols.

multiple TCIP connections

Réponse
 
LinkBack Outils de la discussion
Vieux 06/10/2007, 07h06   #1
vinki
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut multiple TCIP connections

Hello everyone,


I have this code for TCPListenPort. The code works fine, but my
manager is
asking me to establish multiple connections to the same port. How can
i
acheive that

below is my code

Int32 port = Int32.Parse(ConfigurationManager.AppSettings["port"]);

IPAddress localAddr =
IPAddress.Parse(ConfigurationManager.AppSettings["IpAddress"]);
TcpListener server = new TcpListener(localAddr, port);
server.Start();
Byte[] bytes = new Byte[256];
String data = null;

// Enter the listening loop.


while (true)
{
// Perform a blocking call to accept requests.
TcpClient client = server.AcceptTcpClient();
remotePoint = client.Client.RemoteEndPoint.ToString();
data = null;
NetworkStream stream = client.GetStream();
int i;

// Loop to receive all the data sent by the clie nt.
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
// Translate data bytes to a ASCII string.
data = System.Text.Encoding.ASCII.GetString(bytes,
0, i);
// Process the data sent by the client.
data = data.ToUpper();


byte[] msg =
System.Text.Encoding.ASCII.GetBytes(data);
if (msg.Length > 5)
{

byte[] msgClone =
writeClassLibrary.getReturnBytes.ReturnData(_sessi onDisplay, msg);
stream.Write(msgClone, 0, msgClone.Length);
}

}
// Shutdown and end connection
client.Close();


}

  Réponse avec citation
Vieux 06/10/2007, 08h58   #2
Martijn Lievaart
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: multiple TCIP connections

On Fri, 05 Oct 2007 23:06:53 -0700, vinki wrote:

> Hello everyone,
>
>
> I have this code for TCPListenPort. The code works fine, but my manager
> is
> asking me to establish multiple connections to the same port. How can i
> acheive that
>


Get a good book about writing tcp/ip servers on Windows. It's trivial on
Unix with fork(). On Windows, you need to use threads. Not hard, but not
completely trivial either.

HTH,
M4
  Réponse avec citation
Vieux 08/10/2007, 00h19   #3
EventHelix.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: multiple TCIP connections

On Oct 6, 2:06 am, vinki <nitugup...@gmail.com> wrote:
> Hello everyone,
>
> I have this code for TCPListenPort. The code works fine, but my
> manager is
> asking me to establish multiple connections to the same port. How can
> i
> acheive that
>


A TCP connection is identified by the combination of source ip, source
port, destination ip and destination port.

Use a different source port number to establish multiple connections
to the same destination port.

--
VisualEther - http://www.EventHelix.com/VisualEther
Generate sequence diagram from Wireshark (Ethereal)

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,29572 seconds with 11 queries