[Sockets] WSAAsyncSelect vs Separate thread?

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?
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.
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.
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
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.