I am running MSVC++ 6.0 (sp3) on WinNT 4.0ws (sp5).
I am trying to create a some basic concurrent server-client functionality. I have ported code from a unix platform and managed to get it compiled with a little giggery-pokery, but I have a painful bug.
The server side calls runBasicServer() with some params. This spawns a thread (with CreateThread()) and then starts a listener, socket(), bind(), listen(), select(). This is fine and it sees connection requests, and then spawns off another thread to handle the connection via a passed function pointer. The first thing I do, is do a read, since it is non-blocking, i expect a zero to come back from read(). Nope, I get a -1. This is an error so the server disconnects, and thats it.
On the client side, I use a runBasicClient() this connects and then spawns a thread to run the passed client function. THe first thing I do is a write, expecting the number of bytes I wrote... -1... error, client quits.
Because of the server functioning partly correctly, I am assuming the CreateThread does not allow the passing of file descriptors over the thread boundary? I can't seem to find this documented, but it does seem reminiscent somewhere.
How do I use CreateThread() or similar to allow the open file descriptors to be inherited by the child thread?
Worst case, I could spawn the client earlier not providing a status, but I really do want a concurrent server.