I am trying to develop a small chat server with C.
For a simple chat server,
Can i get to see some sample implementations ? I have to use gcc compiler and c language for this assignment.
You need one socket/client and no, you cannot reuse sockets. If you have to handle multiple clients you can:
For C socket communication examples The Unix Network Programming book is probably the best source. It has ample of example programs and explanation.
- ( Transport endpoint ) === ( socket ) ?
NO. "Endpoint" means IP address with Port number. Socket presents one "Session" and session consists of two endpoints, local endpoint(IP, port) and remote endpoint(IP, port).
- Do i have to use one socket per client, or can I reuse a socket for multiple clients ? If so, how ?
One socket per one session. That means a server needs to create a new socket for each remote endpoint( client ). You can reuse socket when it's not in use anymore. Look for SO_REUSEADDR socket option.
- Is there a standard way of doing this ?
Not sure what you are asking. A standard way for chat service or for server/client model? For chat service, look for IRC. Server/Client programming model is well documented. You can Google it.
- Any good references available ?
Now I believe you understand what the error message means.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.