Yeah, just finished a little mandatory project to succeed my lecture “POSIX et C” which I have in my studies-abroad colloqium at UPMC Paris 6 (and I just came up with that name though). This has been a neat, informative lecture and as the title implies, threats the POSIX standards. Apart from those exams to come we had to write a little chat client/server application. As such a client is trivial, the focus lied on the server and off course it was our duty to show as much as possible from the lecture’s topics.
I’m posting it here in case someone is interested how to accomplish certain things with C and POSIX. Quite a comprehensive and well-thought standard but not always easy to get things right and often awkward method naming schemes and general conventions (POSIX evolved from history and is designed-by-committee, so why do I wonder?). Whatever, these 2-clause BSD licensed 500 lines of code show how one could implement a threaded server (with pthreads off course), a minimal thread-safe linked list, a minimal usage example of the almighty select() syscall, brain-dead inter-process communication (via message queues) and a bit off general good C coding behavior (a little state-machine and callbacks example), so there’s some educational benefit in there.
Here is the serious and visually impressive screenshot:
What to do next? How about digging a bit in the XMPP standard and having more fun🙂
Download a source tarball here.
Update: I uploaded a new source tarball, the first one had an issue in the thread-safe list implementation