> [...]
> But the werid thing is that, sometime, the EndSend return 0, so it
> implies that 0 byte of data have been sent, so the my program will try
> to do the BeginSend again and try to send the data again, but the
> result is that the other side will receive 2 same packets. So what is
> wrong with it?
You should not get 0 bytes as a return value for EndSend() unless you
actually called BeginSend() with 0 bytes. If you're using a
connection-oriented socket (eg TCP), no data should be sent at all in this
case, though you will get the successful completion with 0 bytes as the
return value. With a connectionless socket (eg UDP), a 0 length datagram
will be sent.
You don't say what kind of socket you're using. Usually one uses SendTo()
instead of Send() with UDP, but only UDP supports the idea of "packets".
So your post is self-contradictory, making it difficult to know exactly
what it is you're doing.
If you are actually using UDP, then keep in mind that having the same
datagram received twice is a known, correct possible occurrence. With
UDP, you can get a given datagram once, not at all, or multiple times.
If you cannot figure out how it is that you're calling BeginSend() with 0
bytes, you might post the code here to see if someone can help you
identify the problem. Post only a concise-but-complete example of the
code that reliably reproduces the problem. Don't include a bunch of stuff
that has nothing to do with the bug you're dealing with.
Pete
linuxfedora@yahoo.com.hk - 11 Jul 2007 02:14 GMT
On 7 10 , 4 37 , "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > [...]
> > But the werid thing is that, sometime, the EndSend return 0, so it
[quoted text clipped - 26 lines]
>
> Pete
I found that it should be the program logic bug only. Thanks.