473,657 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "outstandin g" 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 2524
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******** ******@TK2MSFTN GP14.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 "outstandin g" 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******** ******@TK2MSFTN GP10.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
2931
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 have a dialog box, wiht two buttoms "Start measurement" and "Stop". "Start" executes a function that do the measurement in the following way.
3
2810
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 then set the new client socket to BeginReceive(). My problem: When two client socket connections send data
1
4875
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 communication class switchable between asynchronous and synchronous. When I use asynchronous udp communication I find that if I want to process a large amount of dns lookups I have one dns provider with many state objects passing through (and a high...
9
8666
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 trying to decide if I should use remoting vs. writing a server that uses networkstreams. I have read that networkstreams\tcp programming should be faster than remoting and is a better choice for what I am doing but that it is difficult to code.
4
3811
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. I've read through what must be dozens of ways to do socket communication in C#, and it seems they all devolve into three basic options - Socket.Select, IOCP through a native interface, and Asynchronous callbacks. I'm fine using Asynchronous...
4
2760
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 implements an asychronous socket server while the embedded devices are the clients When the data comes in over the socket it is eventually passed into a message queue.
4
3599
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 client and asynchronous socket server example code provided in the .NET framework developers guide is a great start but I have not dealt with sockets before and I am struggling with something. From what I can tell the sample server code ...
1
559
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 data to clients, would it use threads from ASP.NET IO thread pool ? Is it a good idea ? Or could it potentially exhaust all threads from IO thread pool and cause problems for web service to access other web services ? Thanks in advance and...
0
1266
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 boost::asio, and also ioxxx, but most of the examples I've seen with them are about sockets. Can they be used for general i/o (files, terminal)? Can anyone point me to good tutorials about using them for stuff other than sockets? My use case...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.