Sunday, April 11, 2010

POSIX Thread programming in C

I have to work on a project for Network programming subject this semester. The project objective is to develop an application that acts as a TCP server on top of UDP socket. Hence our project should take care of everything a TCP server basically and internally does for us, right from three way handshake till 4 way handshake. While there is that, the server have to be concurrent and it should handle few attacks like xmas tree, syn flooding.

So for the concurrency in server handling, our team decided to go with thread instead of forking new process to handle incoming connections since thread is lighter than forking. But the real reason being is I have worked on process creation in Unix for some projects in Undergrad. But I never experimented with thread creation. So what is learning when there is no experimentation involved.

While I am at it, I thought I should also blog the things I learn from thread programming in C. These things usually tend to slip away with time. Hence the post. Now this post may contain very basic instructions but for me these are baby steps. So if you are looking for complex details, this is not the post you should be reading. Thanks.

Misc:

  • Good sources: source1, source2, source3
  • All thread programs need "#include " and while compiling use "gcc -pthread filename.c" to include pthread.h. Hence use IDE to write code but terminal to run the files.

No comments: