Re: creating server socket program to handle multiple client at same time

From: grid (prohit99_at_gmail.com)
Date: 03/15/05


Date: Tue, 15 Mar 2005 11:48:51 +0530


> If yes then when to use then select call(i.e. FD_SET,FD_CLR,FD_SET)?
> if no then select is only thing to have server socket program on one
> pc and other clients on many pcs to have communication with server?

After a connection is received, accept returns a socket file descriptor
which we use for communicating with the client.So here instead of
forking a child you can have a select call and pass this descriptor to
select to tell you when there is activity(read/write) on the socket and
do the communications.

Again,if have a single process handling both accepting connections and
doing I/O , you would also have to pass the socket file descriptor on
which accept is waiting, to select's pool of desciptors.This will help
us to serve clients and also accpet connections at the same time.

> I want to have communication environment with many clients and one
> server serving all at same time.
The design which you have incorporated in your program can also be used
to service multiple clients.You will have to change your program to wait
in a loop for new connections and then fork a child for each new
connection,and then child processess take care of the communication.You
can have you design like :

while loop
      accept connection
      fork a child
child :
       close listening socket
       read/write for/to communication socket
       close socket
Parent :
        close comunication socket

HTH



Relevant Pages

  • Re: TCP Streams from Unknown source to VB.Net
    ... communicate with any types of other platforms on TCP/IP communication. ... the data structure is sent in binary format out over a socket. ... can't contain arrays. ... from the server. ...
    (microsoft.public.dotnet.framework.remoting)
  • Another question about OpenOffice (and component based programming in general)
    ... if my program is going to connect the OO server via socket 8100 ... there is some sort of communication going on. ... If pipe: what is the name of the pipe? ...
    (comp.lang.java.programmer)
  • Re: mysql vs. fork
    ... what's the point in forcing an exit while we are exiting? ... only the at_exit handlers defined in the child process are ... That's bad because the server thinks he has one peer only. ... And if you use the connection's close method chances are that the server shuts down the socket and both clients suffer. ...
    (comp.lang.ruby)
  • Re: stop Socket.BeginReceive before comlpete
    ... Peer-to-Peer Communication Across Network Address Translators ... you will also need the socket to listen to the ... coordinate the two clients). ... Can you enlaborator how did you listen to the Server? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Winsock & IO Completion problem
    ... And it's not a problem to have server and client on both ... I am implementing a communication framework, ... 5.Associate the socket B with the thread pool. ...
    (microsoft.public.win32.programmer.networks)