Unreliable: Networkstream.DataAvailable, Socket.Available, Socket.Poll, Socket.Select
- From: "wayne_osborne"<wayneos@xxxxxxxxxxx>
- Date: Tue, 6 May 2008 06:12:04 +0800
I've written both a synchronous and asynchronous versions of listening
server for file transfer. I'm still looking for a way to know when the file
transfer has completed. I loop on DataAvailable or whatever until it goes
false in order to know that the transfer is complete. I need to know this
in order to validate the wrapping application protocol at the beginning and
end of the buffer. Truncated transfers kill me because validation obviously
fails so the transfer is rejected. I'm trying to transfer 5 to 7 MB files.
Tiny 4K files almost always transfer fine.
Using Networkstream.DataAvailable in the synchronous app only works
consistently well when both the client and server are running on the same
machine. I switched the Networkstream over to async using BeginRead and
EndRead with the AsyncCallback. However, I must add a 200ms Thread.Sleep to
accomodate latency so that whatever "data present" condition can remain true
throughout the transfer. As a result of the sleep, Async ends up way slower
and synchronous. The best I've been able to do so far is a 50ms sleep
following a 10ms Select. It mostly doesn't fail, but takes twice as long as
the synchronous.
I'm thinking about just watching my application buffer until it stops
growing since none of the subject read tests seem to work well over a medium
speed short hop or medium hop connection.
url:http://www.ureader.com/gp/1477-1.aspx
.
- Follow-Ups:
- Prev by Date: Re: select() always blocks non-blocking socket
- Next by Date: Re: Slow registration of group name NetBIOS
- Previous by thread: Re: non-blocking connect might block winsock? ?????????
- Next by thread: Re: Unreliable: Networkstream.DataAvailable, Socket.Available, Socket.Poll, Socket.Select
- Index(es):
Relevant Pages
|
|