Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Question about return 0 in Socket::EndSend in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
linuxfedora@yahoo.com.hk - 10 Jul 2007 07:40 GMT
I have written a program that is using Async Socket,

And the program will send a lot of packet to the socket, and i used
BeginSend and EndSend for sending the data.
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?

Thanks
Peter Duniho - 10 Jul 2007 09:37 GMT
> [...]
> 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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.