rdavisau / sockets-for-pcl

Cross-platform socket API for Xamarin iOS/Android/Forms, Xamarin.Mac/MonoMac, Windows Phone 8/8.1, Windows Store and Windows Desktop.
MIT License
223 stars 72 forks source link

System.Net.Sockets.SocketException #151

Open VasenevEA opened 6 years ago

VasenevEA commented 6 years ago

Hello. Thanks for this beautiful library! I'm try to read data from TCP socket, but... Client.ReadStream.Read(..) generate exception:

System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block. ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <9624f2cab6ac4ffc9c31e9469d40591a>:0 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in <9624f2cab6ac4ffc9c31e9469d40591a>:0 --- End of inner exception stack trace ---

But when I try use Async method client.ReadStream.ReadAsync(..) - I have deadlock... no return from await.

P.S. ReadTimeout - not -1 :) v2.0.2 stable P.S.S. Sorry for my English.

rdavisau commented 6 years ago

Howdy,

That's a strange one that I haven't heard of before - can you give any more information about the platforms involved (iOS, Android, other?), and the nature of the socket you are connecting to? Your english is good :)

VasenevEA commented 6 years ago

I found the reason of System.IO.IOException My TCP server ( hardware module RM04 work in mode - TCP <-> UART-arduino) is..not answering after sometime! It's hardware bug. I think Exception just mean no bytes to read after Timeout. Tested on Android. However issue with ReadAsync is remained.

rdavisau commented 6 years ago

Ah I understand the hardware issue - if you are getting a deadlock it is almost certainly due to the calling code - if you post some of that we may be able to investigate 👍