.Net Socket closing too early

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jeremy S. Richardson (online_at_jerrific.net)
Date: 07/13/04


Date: 13 Jul 2004 11:13:59 -0700

Background:
I have a Legacy C++ application that sends binary data over a TCP
socket. Currently it's talking to a Perl script under Linux.
However, there's a need to port the receving application to Windows.
I rewrote the Perl script receiver as a .Net application in C#.

Problem:
The C# receiver fails to read the last few thousand bytes of data on 1
out of 10 transfers. There is a "socket closed by remote host"
exception on NetworkStream.EndRead().

Other Info:
I can confirm that the Legacy sender application sends all the data
before closing the socket. I'm transferring 1-10MB, and the failure
always happens when there are fewer bytes to transfer than the size of
buffer being used in the receiving application: with an 8K buffer, the
failure will happen with < 8K of data left.

The issue is not consistent. I haven't found any pattern to it.
Sometimes data will go through, but when I send the data again, it
fails. It also never fails this way with the old Perl script receiver
under Linux.

... The socket shouldn't close on the receiver's end with data pending
to be read. Any ideas?

-Jeremy



Relevant Pages

  • CF GPRS-MODEM card on Intel HCCCBCTA1/Cotulla Platform,problem with serial port
    ... Linux version 2.4.19-rmk7-pxa2; ... CPU: XScale-PXA250 revision 1 ... Initializing RT netlink socket ... Keyboard reset failed, no ACK ...
    (Linux-Kernel)
  • Anyone know why the linux select() function is broken?
    ... 1, I sent a packet to a LAN server A, select works ... Anyone know why the linux selectfunction is broken? ... The problem I have isolated is that if a udp socket is openned, ... If there is a receiver however, ...
    (comp.os.linux.development.apps)
  • Re: epoll and timeouts
    ... descriptors to internal socket structures is probably best. ... I don't think I understand why the map is better. ... reason to not use all of the features epoll provides. ... of particular concern with Linux, ...
    (comp.unix.programmer)
  • Re: epoll and timeouts
    ... descriptors to internal socket structures is probably best. ... I don't think I understand why the map is better. ... thought-out interfaces. ... being added to Linux. ...
    (comp.unix.programmer)
  • Re: BSD Sockets Question
    ... since Linux 2.4. ... and mark a socket readable when even a single ... there in the headers but they are noops in the runtime. ... I suspect that the works of Stevens, ...
    (comp.unix.programmer)