beginread

.NET cancel stream BeginRead

I have not been able to find a way to cancel/terminate asynchronous read operation after successful HttpWebRequest. There is no way to set timeout, ThreadPool.RegisterWaitForSingleObject is not working too. And closing the underlying socket is not an option too because neither HttpWebRequest/Reponse provide access to it. Edit: Sadly t...

Is TcpClient BeginRead/Send thread safe?

Using a dotNET TcpClient if I have called an asynchronous BeginRead() on the associated network stream can I still call Write() on that stream on another thread? Or do I have to lock() the TcpClient in the code that is called back from the BeginRead and the code that does the send? Also if I close the TcpClient with: client.GetStream(...

How can you tell the source of the data when using the Stream.BeginRead Method?

When using the Stream.BeginRead Method, and you are reading from a stream into a memory, how is it determined where you are reading the data from? See: http://msdn.microsoft.com/en-us/library/system.io.stream.beginread.aspx In the list of parameters, I do not see one that tells where the data is being read from: Parameters buffer Ty...

[.NET] BeginReceive / BeginRead timeouts

I'm using a NetworkStream & TcpClient to asynchronously receive data using BeginRead. I need to apply a time-out to this operation, such that after a specified amount of time the read will be aborted. As far as I'm able to tell, this isn't supported on NetworkStream or TcpClient - there is a ReceiveTimeout property, but this appears to...