Re: What is better Blocking Sockets or Async?



Blocking is probably the worst socket model with regards
to extensibility (you need two threads per socket), async
is not necessarily the best model either - it requires single-
threaded execution and can bog down a server with
Windows messages. I'd suggest you limit the use of async
sockets to GUI applications. Alternative models to consider
are non-blocking via select, non-blocking via WSAEventSelect,
overlapped via events, and finally - overlapped via events
and I/O Completion Port. The last one is the best model
for a socket server. I'd stay clear of the overlapped via
completion routine model - it can lead to thread starvation
in servers, and unnecessarily complicates clients.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"Michael M." <nospam@xxxxxxxx> wrote in message
news:elOmtUwwHHA.484@xxxxxxxxxxxxxxxxxxxxxxx




.



Relevant Pages

  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... overlapped sockets with an I/O Completion Port. ...
    (microsoft.public.vc.language)
  • Re: Asynchronous socket operations and threadpool
    ... Async sockets really leverage the I/O Completion ... IOCP threads, not .NET threadpool threads. ... socket, then process all that data synchronously. ...
    (microsoft.public.dotnet.framework)
  • Re: runaway thread count and asynchronous sockets
    ... explicitly spawn in my server a normal priority. ... threads spawned by the CLR to handle the async socket communication. ... >> thread you spin off so high thread counts in and of themselves are not always ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: winsock2 query?
    ... Microsoft MVP, MCSD ... > I am writing a client server application. ... > server socket is created, binded & is listening for client connections. ...
    (microsoft.public.win32.programmer.networks)

Loading