On Nov 3, 2011, at 1:01 AM, Igor Russkih wrote:
> As I see Java's InputStream from BluetoothSocket is indirectly mapped into
> System.IO.Stream
>
> How then I can use java's is.available() to detect if there is any data in
> the stream? There is no direct mapping for such a logic in the
> System.IO.Stream.
We're wondering why you need polling access to the stream.
InputStream.available() is documented as not being very useful:
http://developer.android.com/reference/java/io/InputStream.html#available()
"Note that this method provides such a weak guarantee that it is not
very useful in practice."
In particular, is there a reason you don't want to use Stream.BeginRead() or
some other async mechanism? Why do you need polling?
If there's a good need for polling, we're considering providing a `bool
DataAvailable(this Stream stream)` extension method (thus translating the
dubious `int` InputStream.available() return value into a `bool`, and this
mechanism could also check for NetworkStream and return
NetworkStream.DataAvailable), but before we provide this we'd like to know how
useful it actually is.
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid