473,385 Members | 1,379 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,385 software developers and data experts.

Asynchronous sockets and pooled thread loading

I'm working on a proxy which must support at least a dozen simultaneous
connections from local clients to remote servers. It is conceivable that
someone might want to run it in non-local mode, with as many as 3-4
dozen simultaneous connections from remote clients to remote servers.
Supporting that is desireable but optional. The proxy will have to maintain
client/server connections for up to several hours, but the traffic will be
intermittent/bursty. I have no hard requirements in terms of performance.
The proxy does a bit of massaging of the messages that get sent through
it, and I haven't figured out the internal logic. But it isn't out of the question
that I might want to do a BeginReceive and BeginSend on both the client
and server sides. Which would mean four "outstanding" BeginX requests
per proxy * N proxies.

I understand that when a send or receive completes, the callback will be
executed on a some kind of pooled thread. I expect my callback routines
to be fairly lightweight... just some simple text processing, optional debug
oriented logging, and accesses to a shared Hashtable for purposes of
recording/recalling that certain messages & events occurred. I have no
idea of what kind of load the callback/completion routines will put on the
system and can only hope for the best until I get some protocode up and
running or someone points out an obvious problem. What I'm mainly
concerned about ATM is whether the simple act of Beginning many
sends/receives could tie up too many pooled threads.

Could someone give me some sense of how these pooled threads are
actually used between the time a Begin is launched and the request
completes? For example, does a BeginSend cause a thread to be
allocated until all of the data can be written to the underlying socket's
send buffer and the send callback completes? Does a BeginReceive
cause a thread to be allocated only after data is available in the socket's
receive buffer and until the receive callback completes? Thanks.

Nov 17 '05 #1
3 2513
I think this may help you...

http://www.codeproject.com/csharp/AsyncSockets.asp
http://www.codeproject.com/csharp/asyncsockets2.asp
http://www.devnewsgroups.net/group/m...opic13192.aspx
http://www.developerfusion.co.uk/scr...t.aspx?id=3997
http://www.developerfusion.com/show/3997/

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com

"User N" <Us***@invalid.invalid> escribió en el mensaje
news:uL**************@TK2MSFTNGP14.phx.gbl...
I'm working on a proxy which must support at least a dozen simultaneous
connections from local clients to remote servers. It is conceivable that
someone might want to run it in non-local mode, with as many as 3-4
dozen simultaneous connections from remote clients to remote servers.
Supporting that is desireable but optional. The proxy will have to
maintain
client/server connections for up to several hours, but the traffic will be
intermittent/bursty. I have no hard requirements in terms of performance.
The proxy does a bit of massaging of the messages that get sent through
it, and I haven't figured out the internal logic. But it isn't out of the
question
that I might want to do a BeginReceive and BeginSend on both the client
and server sides. Which would mean four "outstanding" BeginX requests
per proxy * N proxies.

I understand that when a send or receive completes, the callback will be
executed on a some kind of pooled thread. I expect my callback routines
to be fairly lightweight... just some simple text processing, optional
debug
oriented logging, and accesses to a shared Hashtable for purposes of
recording/recalling that certain messages & events occurred. I have no
idea of what kind of load the callback/completion routines will put on the
system and can only hope for the best until I get some protocode up and
running or someone points out an obvious problem. What I'm mainly
concerned about ATM is whether the simple act of Beginning many
sends/receives could tie up too many pooled threads.

Could someone give me some sense of how these pooled threads are
actually used between the time a Begin is launched and the request
completes? For example, does a BeginSend cause a thread to be
allocated until all of the data can be written to the underlying socket's
send buffer and the send callback completes? Does a BeginReceive
cause a thread to be allocated only after data is available in the
socket's
receive buffer and until the receive callback completes? Thanks.

Nov 17 '05 #2
"User N" <Us***@invalid.invalid> wrote:
What I'm mainly
concerned about ATM is whether the simple act of Beginning many
sends/receives could tie up too many pooled threads.
No.
Could someone give me some sense of how these pooled threads are
actually used between the time a Begin is launched and the request
completes? For example, does a BeginSend cause a thread to be
allocated until all of the data can be written to the underlying socket's
send buffer and the send callback completes? Does a BeginReceive
cause a thread to be allocated only after data is available in the socket's
receive buffer and until the receive callback completes?


The system maintains a pool of threads. A thread from this pool is
dispatched to execute the callback routine when the async. operation
completes. If there is no available thread in the pool a new one is
allocated. Of course that's a bit simplified description of real works
but you get the idea. And indeed .NET async. sockets demonstrate
unbelievable performance in practice.

Sergei
Nov 17 '05 #3

"Sergei" <se****@nospam.summertime.mtu-net.ru> wrote in message news:eN**************@TK2MSFTNGP10.phx.gbl...
"User N" <Us***@invalid.invalid> wrote:
What I'm mainly
concerned about ATM is whether the simple act of Beginning many
sends/receives could tie up too many pooled threads.
No.


[]
And indeed .NET async. sockets demonstrate unbelievable performance
in practice.


Thanks for the replies.
Nov 17 '05 #4

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

Similar topics

6
by: Zunbeltz Izaola | last post by:
Hi, I have the following problem. I'm developing a GUI program (wxPython). This program has to comunicate (TCP) whit other program that controls a laboratory machine to do a measurement. I...
3
by: Corne Oosthuizen | last post by:
I'm writing a Telnet Server application using Asynchronous sockets. I spawn a listener thread to handel incomming connections and create a separate client socket for each new connection. I...
1
by: Noel | last post by:
Hi, I am a tad confused about if there are any benefits from using asynchronous vs synchronous network communication. As my example, I have been writing a dns lookup stack with a network...
9
by: Michael Lindsey | last post by:
I need to write a server app to send images to client GUIs that are outside of the server's domain. The client will have the file system path to the image but can not access the file system. I am...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
4
by: Macca | last post by:
I am writing an application that uses asynchronous sockets to get data over ethernet from embedded devices, up to 30 concurrent devices.(These devices are written in C). My application...
4
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the results back to the client. The asynchronous socket...
1
by: Navin Mishra | last post by:
Hi, I've an ASP.NET web service that consumes other web services as well as sends data to client using TCP blocking sockets on a custom thread pool threads. If I use asynchronous sockets to send...
0
by: alan | last post by:
Hello all, I'd like to ask recommendations about a "good" generic asynchronous I/O library for C++. By generic I mean, something I can use even on files, stdin/stdout, and sockets. I've seen...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.