C# Socket double connect? -


i wondering, if create socket in c# , connect server, if create thread in program try , annother connectino server, server see 2 connections same place or one?

the code (the socket double-connecting):

iphostentry iphostinfo = dns.gethostentry("127.0.0.1");         ipaddress ipaddress = iphostinfo.addresslist[0];         ipendpoint remoteep = new ipendpoint(ipaddress, 11000);         socket sender = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp);         sender.receivetimeout = 5000;         sender.connect(remoteep); 

and have below code:

thread thread = new thread(new threadstart(doubleconnect));             thread.start(); public static void doubleconnect()     {         try         {             sender.connect(remoteep);         }         catch (exception ex)         {         }     } 

i have question because, on first part of code connect server, dont close connection, creating thread , reconnecting think server see 2 connection same client.

so, server see , 2 connection or 1 connection?

short answer: no.

you calling connect twice on same socket. looked in documentation, says nothing behaviour if that, reckon 2 things can happen:

  1. you exception on second connect (probably socketexception)
  2. nothing. socket connected, falls through second connect call.

but, why not try out , see happens?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -