473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Async sockets vs synch sockets and threads

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.

Sep 19 '06 #1
4 4561
Hello, ny***********@gmail.com!

nI'm writing a server application connection to multiple clients using
nsockets. I want one socket for each client, and the comunication needs
nto be async. I could use the async sockets methods (beginsend,
nbeginrecv...) or I could start a new thread for each client and run the
ncomunication using the sync mehtods (send,recv). What is the best
naproach? 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
Sep 19 '06 #2
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.

ny***********@gmail.com 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.
Sep 19 '06 #3
"simida" <yo**********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
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<foomethods) 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
Sep 19 '06 #4
ny***********@gmail.com 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

Sep 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Morgan Leppink | last post by:
Hi all - We have been developing a complex TCP socket communication app that is responsible for keeping numerous connections open to clients on routable IPs. The app receives request on a...
1
by: Ben | last post by:
I've written a fair amount of sockets code using the Winsock2 API, but I am having some trouble converting to the .Net Sockets API, specifically asynchronous sockets. What I have is a form that is...
0
by: whizpop | last post by:
Hi, First of all, thanks for a great starter kit, now If I could just get it to work (fully). I am trying to compile and run the solution/services all on a local dev box. I am able to...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
4
by: nyhetsgrupper | last post by:
Hi, I've written a async server app. This app start by connecting to a client and then send some data (BeginSend). When the data is sent, the server is starting to listen for incomming data....
10
by: David | last post by:
I have googled to no avail on getting specifically what I'm looking for. I have found plenty of full blown apps that implement some type of file transfer but what I'm specifcally looking for is an...
3
by: Ryan Liu | last post by:
Will TcpClient.GetStream().Read()/ReadByte() block until at least one byte of data can be read? In a Client/Server application, what does it mean at the end of stream/no more data available? ...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.