|
Question : NetworkStream.DataAvailabl<wbr />e returns false
|
|
NetworkStream.DataAvailable occasionally returns false, even when the complete data has not arrived. Is there any workaround for this issue.
|
|
Answer : NetworkStream.DataAvailabl<wbr />e returns false
|
|
DataAvailable is not a blocking call like receive is. It will return false if there is no data available at the precise moment it is called, it is therefore not a reliable method for determining if the remote client had finished sending.
You are better of using Receive() with a timeout and waiting for it to return 0 bytes or if data available returns false go into a timed loop that checks for data available for a given period (i.e. a timeout just like Receive()).
|
|
|