Socket Server which stores information on each of the client

A

aplaton101

What is the best way to create a TCP Server which receives
connections from several sockets and stores information that will be
used for the next connection from each of the sockets. How can I
determine each time which of the socket has made the connection? (the
address of the client socket is not good enough for me because
sometimes the connections are made from several sockets on the same
computer)
 
W

William Stacey [MVP]

1) if connection count is low (i.e. less then 700), then you could start a
new thread with each socket. The socket stays connected with tcp, so you
only need the socket object to talk and refer back to the client.
2) After accept, put the socket object in an arraylist or collection object.
Then have some worker thread(s) servicing the queue/list.

#1 is the easest for server design as the model is easier to program. You
would be well off to get a good book on sockets and server design.

--
William Stacey, MVP

aplaton101 said:
What is the best way to create a TCP Server which receives
connections from several sockets and stores information that will be
used for the next connection from each of the sockets. How can I
determine each time which of the socket has made the connection? (the
address of the client socket is not good enough for me because
sometimes the connections are made from several sockets on the same
computer)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top