You can use pthreads on most platforms.
http://www.cs.nmsu.edu/~jcook/Tools/pthreads/pthreads.html[
^]
On Windows, you can use beginthread() or beginthreadex().
http://msdn.microsoft.com/en-us/library/kdzttdcb.aspx[
^]
As an alternative to creating threads, you can set the accepted socket to non-blocking and use select() for reads, writes, and errors.
http://unixhelp.ed.ac.uk/CGI/man-cgi?select+2[
^]
Here's a beginthreadex() example:
s = accept(Socket,(struct sockaddr*)&client,&len);
if( s >-1)
{
re = new HandleResponse();
re->set_Client(s);
HANDLE handle = _beginthreadex(NULL, 8192, worker, re, 0, NULL);
CloseHandle(handle);
}
Your worker thread procedure could look like ...
static unsigned __cdecl worker(void *context)
{
HandleResponse re = (HandleResponse *)context;
re->run();
return 0;
}