Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SocketAsyncEventArgs and ReadAsync

When using the "SocketAsyncEventArgs" class and ReadAsync, where do i put the read buffer and where do i put the send buffer? or can i only read or send at one time not both? I'm a bit confused.

like image 858
Peter Avatar asked Mar 01 '23 22:03

Peter


2 Answers

I think you're looking for the Buffer property of SocketAsyncEventArgs. This tutorial explains how to use the SocketAsyncEventArgs class properly.

The MSDN article for the class contains some useful remarks and provides example code too (they're almost always a good start).

like image 63
andyp Avatar answered Mar 05 '23 18:03

andyp


You can only use a SocketAsyncEventArgs for a single operation at a time.

To both read and write async at the same time you'll need two SocketAsyncEventArgs objects.

like image 35
hultqvist Avatar answered Mar 05 '23 18:03

hultqvist