PC Review


Reply
Thread Tools Rate Thread

Async sockets vs synch sockets and threads

 
 
nyhetsgrupper@gmail.com
Guest
Posts: n/a
 
      19th Sep 2006
I'm writing a server application connection to multiple clients using
sockets. I want one socket for each client, and the comunication needs
to be async. I could use the async sockets methods (beginsend,
beginrecv...) or I could start a new thread for each client and run the
comunication using the sync mehtods (send,recv). What is the best
aproach? This is a performance critical application.

 
Reply With Quote
 
 
 
 
Vadym Stetsyak
Guest
Posts: n/a
 
      19th Sep 2006
Hello, (E-Mail Removed)!

n> I'm writing a server application connection to multiple clients using
n> sockets. I want one socket for each client, and the comunication needs
n> to be async. I could use the async sockets methods (beginsend,
n> beginrecv...) or I could start a new thread for each client and run the
n> comunication using the sync mehtods (send,recv). What is the best
n> aproach? This is a performance critical application.

Have a look at
( http://msdn.microsoft.com/library/de...ogthrepool.asp )
( http://msdn.microsoft.com/msdnmag/is...s/default.aspx )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Reply With Quote
 
simida
Guest
Posts: n/a
 
      19th Sep 2006
Hi,

Async socket method uses .Net ThreadPool thread to handle async method
process.
As far as I know, .Net ThreadPool is not a high performance way to
process this. Maybe you
can customize a new thread pool model to fit your applicaiton.

( Plz refer to here,http://www.bearcanyon.com/dotnet/#threadpool )

Hope it works.

(E-Mail Removed) wrote:
> I'm writing a server application connection to multiple clients using
> sockets. I want one socket for each client, and the comunication needs
> to be async. I could use the async sockets methods (beginsend,
> beginrecv...) or I could start a new thread for each client and run the
> comunication using the sync mehtods (send,recv). What is the best
> aproach? This is a performance critical application.


 
Reply With Quote
 
Peter Duniho
Guest
Posts: n/a
 
      19th Sep 2006
"simida" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Async socket method uses .Net ThreadPool thread to handle async method
> process.
> As far as I know, .Net ThreadPool is not a high performance way to
> process this. Maybe you
> can customize a new thread pool model to fit your applicaiton.


Actually, .NET async sockets (using Begin/End<foo> methods) use i/o
completion ports if the OS supports them (anything based on NT does), and
IOCP is the best-performing, most scalable mechanism for using sockets. A
special thread pool, the "completion port threads" pool, is used in this
case and used properly should offer excellent performance.

This is all outlined in the first link provided in the previous reply in
this thread.

Pete


 
Reply With Quote
 
Chris Mullins
Guest
Posts: n/a
 
      20th Sep 2006
(E-Mail Removed) wrote in message
> I'm writing a server application connection to multiple clients using
> sockets.


Alright. This sounds pretty common.

> I want one socket for each client, and the comunication needs
> to be async. I could use the async sockets methods (beginsend,
> beginrecv...) or I could start a new thread for each client and run the
> comunication using the sync mehtods (send,recv). What is the best
> aproach?
>


How many sockets do you think will be connected at any given time? If the
answer if "a few" then go with whatever programming mechanism you understand
the best and can debug the easiest.

If the answer is "I'm Not Sure" or "Alot" then you need to use Async Socket.

> This is a performance critical application.


On any modern machine, as long as you follow the rule above, you'll have no
issue with socket performance unless you have some very unusual performance
requirements.

What are your performance requirements, and how do you plan to know if
you've met them?

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing an async client (sockets/async/thread) asharda@woh.rr.com Microsoft C# .NET 8 17th Mar 2008 10:04 PM
Async sockets and threads nyhetsgrupper@gmail.com Microsoft C# .NET 4 19th Sep 2006 12:14 AM
Threads with Sockets in them? or Asynchronous Sockets? Ronodev.Sen@gmail.com Microsoft C# .NET 2 22nd Feb 2006 06:39 PM
Async TCP Sockets mak Microsoft C# .NET 5 15th Jul 2005 11:23 AM
Async sockets Frane Roje Microsoft C# .NET 3 2nd Jul 2004 10:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:17 PM.