strange problems with Socket.Send/Socket.Receive

strange problems with Socket.Send/Socket.Receive

Post by Amade » Tue, 10 Aug 2004 19:36:02

Hello everyone,

I'm having some odd problems with a little program I wrote for
sending/receiving bytes across the network.

I am using synchronous sockets, and it seems that when I send byte
after byte too fast, the packet gets lots somewhere (as odd as that

Here's the sending code:

try {
if (sHandler.Connected)
int cSent = 0;
while (cSent == 0)
cSent = sHandler.Send(byteSend, 0,
byteSend.Lenght, System.Net.Sockets.SocketFlags.None);

catch (SocketException se)

The receiving code is basicly a thread that keeps on running untill
the socket is connected and reads 1 byte per byte. Since i'm using
blocking sockets that seems to work fine.

Simple enough, I use these functions to send chars over a TCP
connection.I read an array of bytes byte per byte and use the function
above to send byte per byte. From what I've tested, if I send too
fast, the receiver never gets all the data. If I would to put a small
delay, like Sleep(1) in there, then everything works fine.

I installed a network sniffer on each workstations I am testing this
code off and as I've said, when I send too fast (as in, no delay after
each byte) the network sniffer on the sender side shows the packet
with the data I'm trying to send, but the receiver's network sniffer
does not. If I put a delay in there, I can see the packet with the
data I'm sending on both sides. I've also tried using a cross-over
cable to remove any possible network interferences and the result is
still the same. As far as the sender is concerned, it sends the data,
and as far as the receiver is concerned, it never gets it.

Does anybody have any idea what's going on, because I'm flat out of

strange problems with Socket.Send/Socket.Receive

Post by Amade » Tue, 10 Aug 2004 20:01:15

After a tad more testing, I have found out that my problem goes away
if I send the whole array of bytes in one .Send command, instead
sending it byte per byte.

Still, the behavior seems a bit odd to me?