2

Please help me clear this concept. Say we have A socket port server implemented using threads. The socket server listens on a socket port and, when a message arrives, create a thread to service the request.

The client code sends a given number of messages to the server. This client code could also be run from different machines by multiple users. I understand that the client code codes are run as seperate processes.Ihat is seperate processes issue requests to the server which is then processed by a server thread.

So, does a client processes stack, user address space, process control block etc pass on to the server thread that processes its request.

Similarly, if it is a file server and a file open request is implemeted by a server thread, then is the fd a part of server file descriptor table or the calling processes.

Would be graatefull to get any link to materials I can read up. Thanks

razlebe
7,1546 gold badges45 silver badges57 bronze badges
asked Jun 3, 2011 at 14:49
4
  • please do let me know why i got negative points...its not a crime to not know Commented Jun 3, 2011 at 15:02
  • it's ok. Points are mostly a game played to keep SO interesting. It's only slightly related to quality of a question, and sometimes people play the game poorly. What you need to learn is networking, and there's a lot of books related to it. I prefer the one by Tanenbaum, but it is very technical. However, if you do manage to get through it, you will have a strong understanding of networking at a very low level. After that you'll just need to learn how to program for it (which is a different thing altogether). Commented Jun 3, 2011 at 15:34
  • the problem is that while you are focusing networking, a lot of your problems are really in understanding how operating systems work. A good book on the evolution of operating systems is "Operating System Concepts" by Abraham Silberschatz. Naturally, to understand that book, it helps to have a good grasp of a programming language, perferably C. Commented Jun 3, 2011 at 15:38
  • @Edwin Thank YOu. Highly appreciate your pointers Commented Jun 3, 2011 at 16:09

2 Answers 2

4

No, the client and the server are different processes, possibly even running on different machines.

Clients will ask the operating system (through the libraries) to send network messages to servers, whose operating system will unpack them and direct them (through the libraries) into the server process.

Now "client handling threads" are a different thing, they are subcomponents of the server process, and in your setup, one of those threads (the one handling the client on the other side of the network) will receive the data and do whatever is needed (possibly including a reply, if necessary).

In the file server situation, the file descriptor provided by the operating system never "leaves" the file server. The file server clients create whatever they need to mirror the contents of the remote machine. Such mirroring might include file descriptors, but they are definitely not the same file descriptors as those that reside on the server. The client file descriptors are bound to code which takes the requested operation and turns it into a network call, while the server file descriptors (likely) access the blocks on disk directly.

answered Jun 3, 2011 at 14:57
Sign up to request clarification or add additional context in comments.

Comments

0

'The socket server listens on a socket port and, when a message arrives, create a thread to service the request.' Nearly. In this type of server design, a new client-server thread is created, (or depooled), when a connection from a client is accepted by the server listening thread. This client-server thread is passed the client-server socket instance that is allocated by the listener thread accept() call. The client-server thread then usually reads from the client-server socket to get messages, HTTP GET/POST, whatever.

'The client code sends a given number of messages to the server. This client code could also be run from different machines by multiple users. I understand that the client code codes are run as seperate processes.Ihat is seperate processes issue requests to the server which is then processed by a server thread.' Yes-ish. There is the possibility that one client on one box may have multiple connections from multiple threads, but you are 99.99% right.

So, does a client processes stack, user address space, process control block etc pass on to the server thread that processes its request.' No! That would be an absolute nightmare!

Similarly, if it is a file server and a file open request is implemeted by a server thread, then is the fd a part of server file descriptor table or the calling processes.

The file/whatever is opened by the client-server thread. All resources/handles allocated by the client-server thread belong to the server.

Rgds, Martin

answered Jun 3, 2011 at 15:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.