Peter Osucha <[EMAIL PROTECTED]> wrote:

> A follow-up to the TCP connection questions...
> 
> Host A which listens for my app on port 6001 has been connected to by a
> machine B running my app.
> 
> If machine C also running my app attempts to connect to Host A, what
> will happen?

It depends, but it should connect, assuming the server (on A) can handle
concurrent clients.

A simple synchronous server often looks very roughly like this:

  serverSocket = CreateServerSocket(...);
  for (;;)
  {
    clientSocket = serverSocket.Accept();
    StartThreadForClient(clientSocket);
  }

Socket.Accept() blocks until a client connects. StartThreadForClient()
above should return as soon as it has passed the client off to another
thread, and return around the loop to listen for another connection.

If the server (listening) program is written like this instead:

  serverSocket = CreateServerSocket(...);
  for (;;)
  {
    clientSocket = serverSocket.Accept();
    HaveConversationWithClient(clientSocket);
  }

... then it won't work, and you'll have to wait for the other client to
disconnect.

-- Barry

-- 
http://barrkel.blogspot.com/

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to