Noro
Noro

Reputation: 1663

Monotouch socket problem

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 another 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?

Upvotes: 0

Views: 616

Answers (1)

balexandre
balexandre

Reputation: 75073

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

Upvotes: 1

Related Questions