Could anyone provide me with the source code for a simple multithreaded server in C that uses UNIX system calls, implementing only the GET command. Or point me to a location where I can view such source code?
Thanks for having a look at my post, sorry i forgot to mention that it is a very simple multithreaded http server I am trying to find the source code for.
Threads in unix are very simple and are created by the the system call pthread_create. The complete format of the system call is pthread_create(pthread_t *pid, const pthread_attr_t *attr, void *(func) (void), void *arg). The pid is the thread ID, the attr is the attributes, usually set to zero (NULL), the func is a pointer to the function that will execute first, and the arg is a pointer to the arguments of that function. Your programme must use first the socket() system call, to establish a socket, then call bind() to bind that socket to a sockaddr_in, then call listen() to make this socket a lstening socket and then call accept(). After accept you will call the pthread_create to handle the connection. It is a good idea to use the manual pages to get more information for the previously mentioned system calls (e.g type man pthread_create).