question

edward-8429 avatar image
0 Votes"
edward-8429 asked LanHuang-MSFT commented

about SocketAsyncEventArgs BytesTransferred

when the receive completed.the SocketAsyncEventArgs.BytesTransferred bytes not equals to the send bytes. How its happens 。

dotnet-aspnet-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @edward-8429,
Do you get it under SocketAsyncEventArgs.Completed ?
It is possible to raise an event on error, you need to test SocketAsyncEventArgs.SocketError for SocketError.Success.
https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socketasynceventargs.socketerror?view=net-7.0
Best regards,
Lan Huang


0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered Bruce-SqlWork edited

Maybe the sender has not flushed the last packet, or the receiver got multiple packets. also unless you use TcpClient, the packets may arrive out of order.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.