What does localhost mean within a Windows terminal services server? Machine or session? [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this questionI'm investigating a project at the moment to create an application which will listen to "localhost" within a Windows terminal services environment.
I don't have access to a test environment at 开发者_运维问答present, but I wanted to check this design, especially what localhost/loopback 127.0.0.1 means within a multiuser machine.
If my application binds a TCP socket listening on 127.0.0.1:40000 then what clients would be able to access this? - would it be open to clients within all sessions for all users on the machine/server? - or would it just be each individual user/session?
I'm hoping/guessing the latter. If this is the case, then can each user in each session open their own app running a listener on 127.0.0.1:40000?
Thanks for any help on this design issue.
I will disappoint you, it's the former.
TCP/IP sockets have no concept of "users" or "ownership": There are 65535 available ports on a given network interface, and there can only be one process listening at any given one. What user owns the process is irrelevant - if you have User1's process listening on 127.0.0.1:40000, then User2's process' attempt to listen on the same port will fail.
Likewise, there is no intrinsic access control: if there's a listening port at a given port, anything that can reach the computer at that port can access the port (in other words, the listening and connecting processes - server and client - don't need to belong to the same user; they might even be on different hosts).
精彩评论