I am working on a tool that will be run by multiple users on the same terminal server. This tools uses TCP sockets to IPC between multiple processes. As multiple instances of the tool will be running at the same by by multiple logged in users, I want to know how are the ports managed on a Windows server? As in, is their a concept of virtual ports that the OS can then map to a system wide unique port or the tools running for different users need to handle this in user space?
Asked
Active
Viewed 1,526 times
3
-
1Maybe you should not be using TCP. Use named pipes which have better namespace isolation. – usr Sep 29 '15 at 21:56
-
@usr I am using zmq for IPC. It does not support named pipes on Windows. – Paani Sep 30 '15 at 05:59
1 Answers
3
The instances of the tool all need to listen at different port numbers, or the same number at different IP addresses.
[Assuming they are listening at all, which isn't stated, but which is the only actual source of concern.]

user207421
- 305,947
- 44
- 307
- 483
-
Listening is not the only concern. Any local binding, whether for listening or connecting, is subject to available ports. – Remy Lebeau Sep 29 '15 at 22:56
-
@RemyLebeau Local binding is never necessary except, apparently, in some cases of VPN which I have never encounted in 25 years of network programming. Edit rejected. – user207421 Sep 29 '15 at 23:11
-
There is always a local binding, whether explicit from `bind()` or implicit from `connect()`. Clients and servers alike have to be careful of local port exhaustion. And there are situations not related to VPNs where a client may need to use an explicit bind (protocol requirements, etc). – Remy Lebeau Sep 29 '15 at 23:16
-
@RemyLebeau If local ports are exhausted there is nothing anyone can do about it except start closing some sockets, and that isn't what the question is about. – user207421 Sep 29 '15 at 23:24
-
Thanks EJP. Yes there is a listening socket. I will modify the tool to dynamically get an available port then. – Paani Sep 30 '15 at 06:02