   Have recv actually wait on another thread? (Winsock & C++)
  Hello, I'm working on a server that is running on 3 threads. It's a public server so I thought if two threads did maybe the hard work it would take of the wait time and heap of to do on the threads.Thread 1 (Main): Handles incoming connections and directs the client to the correct function. (File upload, account check, etc...)Thread 2: Handles downloads of files for the user.Thread 3: Handles uploads of files from the user.So since I'm using this code to tell recv to not wait for input on the first thread is there a way to tell the recvs on another thread to wait to it recives a message? Multithreading and winsock is making me tare my hair out since the recv function isn't as always accurate when it continues on some threads since the recv function doesn't exactly wait forever.Snippet://Initialize after threads initialize.timeval val;val.tv_sec = 0;val.tv_usec = 5;select(NULL, NULL, NULL, NULL, &val);[Edited by - ajm113 on April 23, 2010 6:57:13 PM]
  I don't understand what you want that code to do, but what it WILL do is simply to sleep for 5 microseconds, no matter whether any sockets are open or not.In general, if you use select, and are I/O bound, then threads aren't necessary at all. Meanwhile, on Windows, there is a 64 handle per thread wait limitation, which translates into a 64 sockets per select() "soft limit" (it becomes less efficient after that number). If you expect to have more than 64 connections open at the same time, you really want to use I/O completion ports on Windows.And if you want to use I/O completion ports in C++, your best bet is to use boost::asio...;  Well alright thank you anyways for clarifying what they do! I wasn't too sure about the select function.Well what I did was instead of only doing recv on one end of the server. Was just sending a ready message back to the client saying it's ready for more messages and it seemed to fix the problem, but thanks again!   