• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding the OS user of a client Socket  RSS feed

 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am playing with my little client/server application between HP-UX boxs, learing and trying many things in the process.
Is it possible once I got a Socket from my SocketServer to find out which Unix user initated the call?
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are we talkin' server-side or client-side?
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I still get confused as to what is the client/server. First, let me say why I get confused and I am sure you will set me straight .
The client/server thing is highly metamorphic and that is where I get my confusion. There are times that I view the client/server thing as waiter/diner -- the diner is the client and the waiter serves. However, there are times when I view it (the client/server) as boss/worker -- the boss is the client (or "the one who initiates" ) and the worker serves as requested (or and Exception will be thrown ). Any clarification, links, advice on this is greatly appreciated.
For my purpose I call the server the program which runs the <code>SoceketServer</code>.
Whenever I get a new socket from ServerSocket.accept I can find out the calling host (em client) by:

I would like to get the OS user who initiated the request.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're exactly right on your assumptions. It helps in starting out to think of the client as the process that initiates a request, and the server the process that responds to it. Since ServerSocket's job is to manage incoming requests, that much is academic.
What makes it highly metamorphic, in my view, is that 'client' and 'server' aren't even whole processes, except in simple cases; they're roles. So when a process initiates a request to another process, it's playing the client role; when it receives and responds to a request, then it's playing the server role. This approach makes it a little easier to understand application servers, which as "middle-tier" software perform both roles concurrently; a server to web clients, but a client to back-end databases, directory servers, and so on.
Socket connections themselves are machine-to-machine first, process-to-process second. So the only user context the client passes with vanilla sockets is the client's IP and socket data (i.e., the port addresses it's using for incoming and outgoing data).
After that, what constitutes a user is an OS-specific convention. If the server wants to know more about the client, it has to specify the terms of identification, either through a login process (as with telnet or ftp), digital certificate (client SSL) or something possibly built into the protocol client-server protocol (smtp).
[ November 21, 2002: Message edited by: Michael Ernest ]
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it completely. This was GREAT! Michael you get full credit for having me Feed the Cows
So I guess what I can do is to add another command in my Command Pattern. The Server can then query back the Client . Ooops, we swapped the Client/Server again
Does this make any sense?
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client's the one that initiates the session. A server starts up first, but normally just sits there (unless it's broadcasting) until someone asks it to do something. If either side can initiate, you have a peer-to-peer system, but for a given session, the client can be considered the one that made the first request.
The concept of an "OS User" is not universal nor is there a definitive standard definition or protocols. On the Internet, you don't "log in", and some of the client OS's (for example my old Amiga system or any machine running DOS) you don't even log into the machine, you just fire it up. A DOS network login is a connection made to the LAN manager, not to the local host or to the Internet.
Aside from that, thanks to the magic of network address translation, you don't REALLY know even the identify of the actual client machine - the IP address you get may have been translated from the non-unique set of IPs on the other side of the translation machine, so what you're really getting is usually the IP of the translation machine,
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim this really helps. Can you recommend some further readings?
I am looking for books where things are explained in English and not in science or theory.
Thanks,
Leslie
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!