Unreliable: Networkstream.DataAvailable, Socket.Available, Socket.Poll, Socket.Select



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
.



Relevant Pages

  • Problem with popen
    ... Under linux x86 I'm running a stress test which opens some tcp server ... applications and then about 70 clients in each their thread. ... The server however is started as an async process using fork and then ... sync and async processes. ...
    (comp.unix.programmer)
  • RE: Need Help with Page can not be displayed form my web service
    ... On the server side, when you make a call with Begin/End pairing from the ... async request - ... >the web service. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: context switch
    ... I wrote 2 version, one version still uses sync I/O, one server thread per ... and use same thread write back to client. ... sleep back to client programs. ... server CPU cost up to 98 too. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: context switch
    ... I wrote 2 version, one version still uses sync I/O, one server thread per ... and use same thread write back to client. ... sleep back to client programs. ... server CPU cost up to 98 too. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Windows 2003 Server MACVOL disconnect error
    ... Slect "sleep" tab ... Under Wake Options, ... '--'We have a Windows 2003 Server with a MACVOL configured to store files for 8 ... '--'because data is typically not lost when the disconnect occurs, ...
    (microsoft.public.windows.server.networking)