1

I'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.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Stuart
  • 66,722
  • 7
  • 114
  • 165
  • 2
    To whoever voted to close: this is a question about whether I can develop a program which uses localhost in terminal services. IMHO it's definitely a software development question and so is in line with the FAQ. – Stuart Sep 16 '11 at 09:11

1 Answers1

2

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).

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • Thanks Piskvor - that does make sense. I guess I just don't know what terminal services is... I kind of hoped every user got a separate VM - each VM with its own localhost adaptor, but I guess I need to understand sessions are different to VMs. Thanks! – Stuart Sep 16 '11 at 10:24
  • @Stuart: You're welcome. As for TS, normally they're all executing on the same computer, without any virtualization. Each user only gets their own virtual *display*, but that's pretty much all - the rest of the computer (networking, processes etc) are shared. – Piskvor left the building Sep 16 '11 at 10:26
  • Thanks again - I'm learning:) Does that mean they also share all folders like "program files" - they just get their own "My Documents"? (Sorry - should really ask these as separate questions - or should just go read up!) – Stuart Sep 16 '11 at 12:13
  • @Stuart: Actually, yes, that'd be better as a separate question (on ServerFault perhaps?) – Piskvor left the building Sep 16 '11 at 12:29