Chat Server with sockets in C

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-09-14T18:09:42Z Indexed on 2012/11/02 5:02 UTC
Read the original article Hit count: 193

Filed under:
|
|

I'm trying to write a chat server in C that allows communication between two clients using POSIX sockets. I'm not sure I have a good grasp on this concept or how I should set up the communication protocol between the clients and the server.

I know I need one socket to bind() the server port to so I can accept incoming connections from clients, but in order to have two clients connected at the same time do I need to create a socket for each of these clients when I accept() or should I accept() a client and then fork() so I can have another client accept? I'm not worried about concurrent chatting yet, it's more of a ping-pong approach where the clients need to wait for a recv() after they send() before they can type a new message.

© Stack Overflow or respective owner

Related posts about c

    Related posts about homework