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

Async socket IO

Hi

I have a question about Sockets in C#.

Is it possible that the BeginReceive returns an AsyncResult where
CompletedSynchronously is set to true.
I would think it is, this is the way Overlapped IO worked in Win32.

Now, if this happens,
A. Is the Callback method executed?
B. Is this executed inside the caller thread or still on the
threadpool.
C. Is the callerthread blocked until this callback is executed?

kind regards

Alexander
Nov 16 '05 #1
2 3107
And if I do need to check for this,

wich one is correct. Do I need to check the IsCompleted or
CompletedSynchronously member?

private void StartReceive(){
IAsyncResult Result;

do {

Result = Socket.BeginReceive(FReceiveBuffer, 0, 1024,
SocketFlags.None, new AsyncCallback(OnReceiveCallback), this);

} while (Result.CompletedSynchronously);

}

private void StartReceive(){
IAsyncResult Result;

do {

Result = Socket.BeginReceive(FReceiveBuffer, 0, 1024,
SocketFlags.None, new AsyncCallback(OnReceiveCallback), this);

} while (Result.IsCompleted);

}
Nov 16 '05 #2
Hi Alexander,
I have a question about Sockets in C#.

Is it possible that the BeginReceive returns an AsyncResult where
CompletedSynchronously is set to true.
I would think it is, this is the way Overlapped IO worked in Win32.

Now, if this happens,
A. Is the Callback method executed?
Yes, when you call EndReceive.
B. Is this executed inside the caller thread or still on the
threadpool.
On caller's thread.
C. Is the callerthread blocked until this callback is executed?


Yes. It blocks when you call EndReceive.

bye
Rob
Nov 16 '05 #3

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

Similar topics

1
by: Joshua Coady | last post by:
I am writing a class that includes several async methods following the BeginXxx, EndXxx pattern. Some of these methods will call methods in the framework such as Stream.Read or Socket.Send. Do I...
2
by: dream machine | last post by:
Hi all , with BegeinReceive I can build async method of Socket Class that Receive the data from the Socket Client . My question is , if I have this code that create 3 Receive Async Call : ...
1
by: Mark Smith | last post by:
Hi , Is it possible in .Net to define a async timer callback. What I am wanting to do is declare a time-out condition that gets executed should the something timeout. The reason I want to do...
8
by: MuZZy | last post by:
Hi, Could someone pls help me here: If i use async sockets in the separate thread like this: void ThreadFunction() { ..... 1. MySocket.BeginAccept(AsyncCallBack(OnConnectRequest),...
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...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
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...
10
by: ColoradoGeiger | last post by:
I have a fairly standard server application that I am using asynchronous socket calls to make connections, send and receive data, and all of that jazz. No blocking methods was my goal in writing...
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
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
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...

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.