My software need to listen to 2 different ports at the same time, I need something like that :
Client.Connect("127.0.0.1", 8001);
Client.Connect("127.0.0.1", 8002);
Is it possible ?
My software need to listen to 2 different ports at the same time, I need something like that :
Client.Connect("127.0.0.1", 8001);
Client.Connect("127.0.0.1", 8002);
Is it possible ?
Not with a 1 connection, TCP Clients are connected individually so you need to make 2 port connection for multiple connectivity. For example, in Terminal you can't have multiple connection until you open a new window for second connection.
See Borealid answer on here, give you some clear view, but there is more to it.
For a stateful protocol (like TCP), a connection is identified by a 4-tuple consisting of source and destination ports and source and destination IP addresses. So, if two different machines connect to the same port on a third machine, there are two distinct connections because the source IPs differ. If the same machine (or two behind NAT or otherwise sharing the same IP address) connects twice to a single remote end, the connections are differentiated by source port (which is generally a random high-numbered port).