> What is basically happening is if I do an immediate Read after I write to
> the network stream. Read returns immediately with an empty buffer[]
[quoted text clipped - 11 lines]
> timeout
> expires.
Huh.
As much as I hate to say it (I'm always writing "it's not a bug in .NET"
because so many people are accusing .NET of having a bug when it's in
their own code :) ), I think maybe in this case you've found a bug in .NET.
It _seems_ to me that the NetworkStream() you get frmo TcpClient should be
exactly equivalent to the NetworkStream() you can get from a Socket. So
if the Socket works fine but the TcpClient does not when doing the same
exact thing, I'd say the TcpClient is broken somehow.
One minor point: you mention setting the ReceiveTimeout property. I don't
think that this should result in, or somehow prevent, the call to Read()
completing immediately. However, do keep in mind that if you set a
timeout for receiving, that if the timeout occurs, the socket is no longer
usable. I believe the same thing is true for TcpClient. If you want a
timeout, but want to be able to continue waiting for data on the socket
afterwards, you'll want to implement your own timeout logic (which would
require using asynchronous methods) rather than using the ReceiveTimeout
property.
Pete
AL - 13 Jul 2007 08:46 GMT
Hi
Thanks for the feedback. I would like to hope it's not a framework bug,
however am happy that I have gotten some more information.
Many thanks
> > What is basically happening is if I do an immediate Read after I write to
> > the network stream. Read returns immediately with an empty buffer[]
[quoted text clipped - 34 lines]
>
> Pete