[Sockets] WSAAsyncSelect vs Separate thread?

Jul 2, 2012 at 10:30pm
I heard over some other coding forums that it would be best to have a separate thread when reading constant data (screaming) is this true or is there a better method of handling streams?
Jul 3, 2012 at 10:47am
if you use a thread doesn't depend on the use of sockets. It depends on the tasks you want to accomplish. Whether they should run at the same time or not.

Even a server might be single threaded when the tasks a short enough.
Jul 3, 2012 at 4:18pm
What coder777 says is accurate. I just want to add this: If you need to process or collect data uninterrupted maybe a separate thread is a good idea. Usually the main thread is a UI thread that needs to repaint windows, handle keyboard and mouse, etc. That takes time and may render it inappropriate for your data collection needs.

So that's where you decide: A new thread dedicated to the collection of data or data collection being interlaced with other "mundane" tasks in the window procedure/message pump.
Jul 3, 2012 at 6:35pm
I have found async sockets to be a royal pain and you're forced to deal with a whole new class of error (socket not ready).

Surprisingly, if you don't get it right, the code uses more CPU and lower network performance.

If you don't have to use them, don't.
Last edited on Jul 3, 2012 at 6:39pm
Jul 3, 2012 at 8:43pm
I have found async sockets to be a royal pain and you're forced to deal with a whole new class of error (socket not ready).

Surprisingly, if you don't get it right, the code uses more CPU and lower network performance.

If you don't have to use them, don't.


That's why i usually use blocking sockets in a separate thread, the best compromise IMO
Topic archived. No new replies allowed.