BeginSend
function does not throw exception when I disconnect iPad from Network. Interesting thing is that OnSend
callback function calls and result.
Iscompleted
returns true.
If I call anothe开发者_JS百科r overloaded function with error code, it always return success
tcpAsyCl.BeginSend(
write_data,
0,
write_data.Length,
SocketFlags.None,
out error,
new AsyncCallback(OnSend),
null);
if (error != SocketError.Success)
throw new Exception("Not connected"); //never goes her
Does anyone know this behavior?
as It's an async call! You can't verify the result in the line below... I'm sure you have a method that you can hook up to get the correct error.
Asynchronous calls are created in a new thread and it's there that you need to wait for the answer. Not in your main thread, or that would be a Synchronous call.
here is a list of all methods that you can use
I would strongly suggest that you take a deep look at this document
Using an Asynchronous Client Socket
精彩评论