C # Stream.BeginSend

1

As you can see in the link below, the StreamReceiver method uses the BeginRead method to read asynchronously, since in the SendData method no asynchronous writing is used, what is the logic of reading asynchronously and writing synchronously?

In order to get a good performance, since the read and write data stream would be almost equivalent, should BeginSend be used to write asynchronously?

link

    
asked by anonymous 08.06.2014 / 19:59

1 answer

0

Depends on the size of the buffer. You read or write asynchronously when you want to take advantage of the available CPU cycles while you wait for the information to be transferred over the network.

In your example, it would make sense if writing is too little and reading is a ton of things. So the BeginRead callback response is huge.

Now, if both are large buffers, it does not make sense as it is implemented.

In my blog ( link ) there are some things about asynchronous I / O that can help you understand the difference.

    
14.07.2014 / 20:10