A simple chat server with unix sockets.
Author : Jaseem Abid email@example.com License : GPL V3
- compile the server code
gcc server.c -o server -pthread
- compile the client code
gcc client.c -o client -pthread
- Run server
./server <port number>. Eg:
- Run the client in a different terminal.
./client <server> <port>. Eg:
./client localhost 8089
- Run any number of clients in different terminals
- Send messages to user in the format
<userid> <Message>. Eg:
1 hello world
Code tested on an ubuntu 10.04 LTS machine with gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
A message can be sent from peer to peer in the format '@ Message'
It is assumed now that the entered peed id is valid integer. A '*' will enable users to broadcast message to all logged in users at the same given time.
@3 Hello world :)
Clients use a multi threaded approach to recieve and send messages the same time. A thread runs listening to the socket and one to stdin. This enables concurrent chat between multiple users.
- Original source of the demo codes : http://www.linuxhowtos.org/C_C++/socket.htm
- Threading tutorial : https://computing.llnl.gov/tutorials/pthreads/
- A good place to start learning git would be https://gist.github.com/1210107
If you have any questions, please feel free to ask me at firstname.lastname@example.org