Afficher un message
Vieux 06/10/2007, 08h06   #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
 
Page generated in 0,04765 seconds with 9 queries