Click to See Complete Forum and Search --> : Asynchronous vs Synchronous sockets.


Orion Mazzor
May 6th, 1999, 06:16 PM
Which is better suited to what? It makes sense that synchronous sockets need to be run using threads, and that asyncronous doesn't. But can a server setup with asynchronous sockets handle more connections/load then an a server with synchronous sockets? Consider the following situation:

[--snip---]
A server will handle a high volume of people that will be connected to the server over a long period of time. There isn't a lot of traffic that will be going back and forth, but there is the potential of a lot of traffic.
[--snip---]

The socket code could be setup to be synchronous, and each connection is sitting on it's on thread. Any packets that come in, are posted to a message que that the main thread reads from.

Or

The socket code could be setup to be asynchronous, and each connection sits in a list of connections. Any packets that come in, are posted to a message que that the main thread reads from.

What would be the best way of approaching this?

Thanks
Orion

Samir Sanghani
May 9th, 1999, 03:05 AM
Orion,
Usage of asynchronous or synchronous depends on your requirement. if the protocol using which you would be communicating is synchronous such as ftp which maintains a session of who ever is logged in the implementation is easier using synchronous sockets.
In case of http protocols asynchronous sockets would be a easier implementation.
Also be careful when you use threads with MFC Socket abstraction classes. You cannot pass a instance of CSocket across the thread.
Samir

Orion Mazzor
May 9th, 1999, 11:17 AM
I'm designing both the client and the server, so it's just a matter of figuring out which is a better implimentation, and how many threads and sockets NT can have.

Orion