0

I have seen a lot of tutorials on client/server chat rooms using sockets, I am trying to create a instant messenger which will allow users (stored in a sql db) to chat with there contacts and groups(also stored on sql db). now I am really puzzled where to start. how would i go about creating a server which can handle peer to peer chat and group chat. I am using a mysql database which will store the user data and contacts list.

2 Answers 2

0

To get you started on ServerSocket and ClientSockets for multiple clients you can refer to the below post. Two Socket sharing a port

Ideally every client would have only 1 socket connection to the server. To differentiate between your chats you can very simply use a unique identifier which will help differentiate between the different chat types.

2
  • thanks for the reply, so do you mean that ever client would have a socket each which would connect to ONE socket in the server or will the server have to have a socket for each client socket. Apr 25, 2014 at 12:20
  • The Server would have 1 ServerSocket. Multiple clients (each with a Socket of their own) would connect to the same ServerSocket in the server. Apr 25, 2014 at 12:22
0

You will need to create a multi-threaded socket server, this will accept incoming connections on a loop, and then pass off all operation between that instance of the socket and the client into a separate thread. This will allow you to run multiple client connections at once. This Page goes into great detail about creating both single and multi-threaded chat servers.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.