简体   繁体   中英

I would like to maintain three tcp/ip client connection with in a same machine and those will be connected to one server is it possible?

I am working with one requirement. Where I need to maintain three tcp/ip clients and those need to connected to the same server.

Is it possible to Run those three clients in a same machine.?

If not possible, if I need to run those clients in a three remote machines and those need to be connected to the same server, Then how could i synchronize those clients.?

I am glad if any suggestions.Thanks in advance.

Sure, why wouldn't this be possible? Those three clients can even connect to the same remote port.

Yes, it is very much possible tcp connections are identified by 4-tuples

(src ip,src port, dest. ip, dest.port)

Here if you run your clients on the same machine they all have the same source ip, so their source ports will have to be different. Then all 3 of the clients can connect to the same server listening on a single port.

These 3 connections can be distiguished because one of the 4-tuple items (The source port) is different for each.

As pointed out by @Remy The OS by default assigns unique port numbers (source ports) to the Applications, but if you specifically bind to a certain port, the onus is on you to bind it to a unique port number.

Yes surely that should not be problem. Even within a same thread you can do that. Example here. you can create more objects of the class tcp_client_c...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM