473,766 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(asynch tcp client) I'm missing something with this example

http://msdn2.microsoft.com/en-us/lib...2a(VS.80).aspx

I was looking at above link and I just don't see the advantage of this. The
main thread is just stopping and waiting for each of the
connects/sends/receives to complete anyway so it seems to me using the
synchronous methods would be much simpler and equivalent as far as
efficiency/performance in this example? What am I missing here? Is it just
that this example is simply to show the structure of putting the begin/end
asynch calls together and not demonstrating a practical use?

any input on this would be greatly appreciated. A good practical example of
asynchronous tcp client/server would be gold to me right now.
Apr 18 '07 #1
6 1970
HI,

Maybe in this case it like that. It's an example after all.

The point is that with an async you can do other stuff (or at the least no
block the UI) while you transfer the data.

"David" <no****@nospam. comwrote in message
news:eH******** ******@TK2MSFTN GP04.phx.gbl...
http://msdn2.microsoft.com/en-us/lib...2a(VS.80).aspx

I was looking at above link and I just don't see the advantage of this.
The main thread is just stopping and waiting for each of the
connects/sends/receives to complete anyway so it seems to me using the
synchronous methods would be much simpler and equivalent as far as
efficiency/performance in this example? What am I missing here? Is it just
that this example is simply to show the structure of putting the begin/end
asynch calls together and not demonstrating a practical use?

any input on this would be greatly appreciated. A good practical example
of asynchronous tcp client/server would be gold to me right now.

Apr 18 '07 #2
<"Ignacio Machin \( .NET/ C# MVP \)" <machin TA laceupsolutions .com>>
wrote:
Maybe in this case it like that. It's an example after all.

The point is that with an async you can do other stuff (or at the least no
block the UI) while you transfer the data.
It depends on the situation. In the case of a server, I'd say the main
point of async IO is to be able to handle thousands of clients without
the context switches involved in running thousands of threads.

Chris Mullins is the person to ask though :)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 18 '07 #3
JR

"Jon Skeet [C# MVP]" <sk***@pobox.co m???
??????:MP****** *************** ***@msnews.micr osoft.com...
<"Ignacio Machin \( .NET/ C# MVP \)" <machin TA laceupsolutions .com>>
wrote:
>Maybe in this case it like that. It's an example after all.

The point is that with an async you can do other stuff (or at the least
no
block the UI) while you transfer the data.

It depends on the situation. In the case of a server, I'd say the main
point of async IO is to be able to handle thousands of clients without
the context switches involved in running thousands of threads.

Chris Mullins is the person to ask though :)
The main thread is just a harness for the sample routines. It is not a real
user. One should use asynch I/O when one needs it. For example, when you
want your GUI to be responsive even when the other party fails.

JR
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 19 '07 #4
thanks all...

"David" <no****@nospam. comwrote in message
news:eH******** ******@TK2MSFTN GP04.phx.gbl...
http://msdn2.microsoft.com/en-us/lib...2a(VS.80).aspx

I was looking at above link and I just don't see the advantage of this.
The main thread is just stopping and waiting for each of the
connects/sends/receives to complete anyway so it seems to me using the
synchronous methods would be much simpler and equivalent as far as
efficiency/performance in this example? What am I missing here? Is it just
that this example is simply to show the structure of putting the begin/end
asynch calls together and not demonstrating a practical use?

any input on this would be greatly appreciated. A good practical example
of asynchronous tcp client/server would be gold to me right now.

Apr 19 '07 #5
The sample is showing you how to do basic async socket programming, but it
is (as you point out) really defeating the purprose by doing so much
waiting.

Async sockets are good for handling lots of sockets very cheaply, and for
helping you not have to create and manage your own threads.

There are a number of better examples that Microsoft has put out. Their
server sample of that same program is a bit better: This creates a server
socket, that just echo's things back to the sender. Pretty straight forward.
http://msdn2.microsoft.com/en-us/library/fx6588te.aspx

There are a ton of examples on CodeProject that use async sockets:
http://www.google.com/search?hl=en&q...om&btnG=Search

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

"David" <no****@nospam. comwrote in message
news:eH******** ******@TK2MSFTN GP04.phx.gbl...
http://msdn2.microsoft.com/en-us/lib...2a(VS.80).aspx

I was looking at above link and I just don't see the advantage of this.
The main thread is just stopping and waiting for each of the
connects/sends/receives to complete anyway so it seems to me using the
synchronous methods would be much simpler and equivalent as far as
efficiency/performance in this example? What am I missing here? Is it just
that this example is simply to show the structure of putting the begin/end
asynch calls together and not demonstrating a practical use?

any input on this would be greatly appreciated. A good practical example
of asynchronous tcp client/server would be gold to me right now.

Apr 19 '07 #6
thanks Chris. Its appreciated.

"Chris Mullins [MVP]" <cm******@yahoo .comwrote in message
news:eC******** ******@TK2MSFTN GP04.phx.gbl...
The sample is showing you how to do basic async socket programming, but it
is (as you point out) really defeating the purprose by doing so much
waiting.

Async sockets are good for handling lots of sockets very cheaply, and for
helping you not have to create and manage your own threads.

There are a number of better examples that Microsoft has put out. Their
server sample of that same program is a bit better: This creates a server
socket, that just echo's things back to the sender. Pretty straight
forward.
http://msdn2.microsoft.com/en-us/library/fx6588te.aspx

There are a ton of examples on CodeProject that use async sockets:
http://www.google.com/search?hl=en&q...om&btnG=Search

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

"David" <no****@nospam. comwrote in message
news:eH******** ******@TK2MSFTN GP04.phx.gbl...
>http://msdn2.microsoft.com/en-us/lib...2a(VS.80).aspx

I was looking at above link and I just don't see the advantage of this.
The main thread is just stopping and waiting for each of the
connects/sends/receives to complete anyway so it seems to me using the
synchronous methods would be much simpler and equivalent as far as
efficiency/performance in this example? What am I missing here? Is it
just that this example is simply to show the structure of putting the
begin/end asynch calls together and not demonstrating a practical use?

any input on this would be greatly appreciated. A good practical example
of asynchronous tcp client/server would be gold to me right now.


Apr 23 '07 #7

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

Similar topics

18
7384
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure client-side javascript. I forgot to bookmark it, and now I can't find it. Anyone?
11
1766
by: Glen Wolinsky | last post by:
This is my first attempt as asynchronous processing. I have created a small test app as proof of concept, but I am having one proglem. In the example (code listed below), my callback routine has two problems: 1. It runs TWICE; and 2. While it seems to update the web page controls, the results never show up on the page. I am using delegates per a couple of examples I found on MSDN and elsewhere.
2
1565
by: ghost | last post by:
As the Subject indicates I have written a web page that makes use of several web service calls. Some of the web service calls are very fast so they called synchronously. Some web service calls are longer running so I call them asynch so that they can all run concurrently. The user base for the application that I am creating demands the partial response of the faster calls and a gradual update of their web page info from the balance of...
5
1847
by: Ric | last post by:
I created a page in ASP.Net (with no buffering) that does the following: Output line #1 FLUSH {wait 1 second} Output line #2 {wait 1 second} Output line #3 FLUSH
1
2641
by: Sean | last post by:
I am looking at using delegates to perform an asynchronous call. There will be a callback invoked at the end of the call. The client thread will wait on the WaitHandle from IAsyncResult (which is really a AsyncResult). My question is, when exactly is this WaitHandle signalled - is it: -when the asynchronous call finishes OR -when EndInvoke() is called (by the callback)
4
1877
by: EM_J | last post by:
I am implementing this interface in one of my pages. The RaiseCallbackEvent method runs a task for about 3 seconds. I've noticed when I am on that page and click a tab to navigate to another page, it may take up to 3 seconds to redirect. If I decrease the time to 500 ms, the redirect happens much faster. So it seems like this asynch task is not really asynch, since the redirect is waiting for it to complete. Am I misunderstanding...
0
1030
by: =?Utf-8?B?Um9iIEM=?= | last post by:
I have an application written in VC++ using MFC that calls into web service written in C#. I am developing in VS2005. I am debugging my C++ app while I have attached my Webservice project to the debugger through a seperate VS2005 process. I make a call to the webservice to update some records in SQL Server. I have a breakpoint in the webservice method prior to the actual daabase update call. When I run this, the code breaks on the...
0
1371
by: Patino | last post by:
I have a particular WS consumer application (Windows app) that was not able to read an error from the WS app because it was calling a method asynch. The client app just hangs there. But once I switched the call to a synch, the client app got the error message and displayed it nicely to the user. In this client app. the user does not have to do anything while waiting for results to come back from the web, so it makes sense to call the...
6
2620
by: Frank Hauptlorenz | last post by:
Hello out there, I have 2 services running. The first one runs in session mode and the 2nd not. The first one should call an operation of the 2nd one asynchronously, because this is doing some long running calculations. If this call is synchronously, everything is running okay. If it's call async the operation does not even start. (I've setup up some event log message at the entry point).
0
9571
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
9404
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
10168
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...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
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
7381
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
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.