Async TCPClients



Hi all,

Three questions really:

1) The async call to the networkstream's endread() (or even endxxx() in
general) blocks. Async calls are made on the threadpool - aren't we advised
not to cause these to block?

2) You can connect together a binaryreader to a networkstream:

BinaryReader reader = new BinaryReader(stream);

And then read an int from it:

int i = reader.ReadInt32();

And vice versa.

Since there are no calls to beginread/endread, I presume this isn't a
synchronous call. Is there any way to make it async? Or am I missing the
point?

3) I'm trying to implement the message mechanism described here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp09182003.asp

In order to answer question 2), I'm going to read the the messagetype
asynchronously, but the rest of the message synchrounously in the callback
(by tying together the binaryreader and networkstream). Is it a good idea to
do mix the two like this? What happens if the network lags, or bytes go
missing?

Thanks!

Shak







.



Relevant Pages

  • Async TCPclient
    ... Async calls are made on the threadpool - aren't we advised ... You can connect together a binaryreader to a networkstream: ... And then read an int from it: ...
    (microsoft.public.dotnet.framework.remoting)
  • Async TCPClients
    ... Async calls are made on the threadpool - aren't we advised ... You can connect together a binaryreader to a networkstream: ... And then read an int from it: ...
    (microsoft.public.dotnet.distributed_apps)

Loading