Topics: Bluetooth - Microsoft
Apr 16, 2012 at 1:40 PM


I'm working on application Host=>Client  Bluetooth device developed on VB2008 .net 3.5:

If I use the property NetworkStream.ReadTimeout=100, when the MioNetworkStream.ReadByte method is executed (and there isn't byte from Client)  the IOexception is generated, and the property MiaBluetoothClient.connected become false !

Is it normal ? what I must to do ? I must reconnect, and what ?

  Help me !


Apr 18, 2012 at 5:28 PM

Yup that's the expected behaviour.  See e.g. MSDN on ReadTimeout "If the time-out period is exceeded, the Receive method will throw a SocketException."  And of course any error closes the socket.  Are you aware that Read will return as soon as any data (even one byte arrives) not waiting for the full requested buffer length.

In most network protocols the receiver know how many bytes are expected and just loops until they've arrived or an error/timeout has occurred. For instance some protocols send a line for each commant response and one can read until the CR/LF are received (e.g. with StreamReader.ReadLine), other protocols use another terminator character, and some send a one/two byte length value and that that data thereafter.

Apr 19, 2012 at 5:56 AM

Thanks, for reply !

I solved it by using the property .DataAvailable

we resent the next time, regards