开发者

Monotouch socket problem

开发者 https://www.devze.com 2023-03-08 09:55 出处:网络
BeginSend function does not throw exception when I disconnect iPad from Network. Interesting thing is that OnSend callback function calls and result.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消