简体   繁体   中英

C# Have server see the difference between clients on IP:Port

So let's say I have a server on IP Address A. And two clients on IP Address B using software that is using the TcpClient class. If both clients are listening in two different IPv4 addresses but on the same port. How will a server be able to reply with data to both of the clients using a TcpClient and a networkstream?

It's a bit difficult to try this for me at the moment considering I only have access to one computer at the moment and I can't have two tcplisteners on the same port on one computer.

Thanks

Edited for clarification.

First of all, only use one TcpListener, and do so in the server. The clients should connect to the server, not the other way around. This way, on the clients' computers, you'll be assigned a random available port to communicate with the server.

Second of all, you could use virtual machines to test on a single machine, or run the server and clients on the same computer, that would still work. Good luck!

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