HELP (server?)

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?

any help will save my bacon!

Regards Gee :frowning:

What kind of server? What are you trying to accomplish? You mention 'GET' are you asking about a web (HTTP) server?

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.

All I want it to do is listen at port 8080.

When I point my browser to http://localhost:8080/ it will display my home directory.

I am very new to Unix and network programming and any help would be greatly appreciated.

Regards Gee.

Why you wouldn't use Apache I don't know but...

If you want to "play" with an httpd server, try...

http://hoohoo.ncsa.uiuc.edu/

...you can download the source. It's small, fairly complete
but totally unsupported.

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).