tags:

views:

420

answers:

2

Will Socket.SendAsync allways send all data in the byte[] buffer that the SocketAsyncEventArgs has been assigned with? iv tested some code but only on a local network and there it seems to be that way..

Edit: Ok but does it allways send all data befor running the compleated event?

the only socket.BeginSend did not if i remember right..

+1  A: 

No it will not. There are a lot of factors to consider here including buffering, timeouts, etc ...

The simplest to consider though is the limit on packets at the IPV4 level. IPV4 packets have a strict limit that cannot be exceeded (65,535 bytes). It's therefore not possible for SendAsync to push data which is larger than an IPV4 packet size into a single packet.

JaredPar
+1  A: 

It will attempt to send all data, however, from the docs on MSDN:

"For message-oriented sockets, do not exceed the maximum message size of the underlying Windows sockets service provider. If the data is too long to pass atomically through the underlying service provider, no data is transmitted and the SendAsync method throws a SocketException with the SocketAsyncEventArgs.SocketError set to the native Winsock WSAEMSGSIZE error code (10040)."

There are times when a buffer that is too large should be split up. It depends on the underlying socket implementation.

Reed Copsey
is there any way to detect the buffer size or is there any safe size?
Petoj