C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 03-25-2005, 10:36 PM   #1
Registered User
 
Mortissus's Avatar
 
Join Date: Dec 2004
Location: Brazil, Porto Alegre
Posts: 152
UDP programming

Hi! I have some doubts about UDP programming. Iīve been trying to find answers, but couldīt find . Any link or response is much appreciated!

1) Can I send and receive using the same socket in multithread? Must I use semaphores?

2) If two hosts send something at the same time, both the datagrams will be sent, or they will be dropped? I know that UDP is a little unreliable, but can this kind of error occur, or Ethernet protocol deals with it?

Again, thanks any help.
Mortissus is offline   Reply With Quote
Old 03-25-2005, 10:51 PM   #2
Registered User
 
Join Date: Jan 2005
Posts: 847
Quote:
Originally Posted by Mortissus

2) If two hosts send something at the same time, both the datagrams will be sent, or they will be dropped? I know that UDP is a little unreliable, but can this kind of error occur, or Ethernet protocol deals with it?
Do you mean 2 hosts each sending a datagram to each other? In that case both would be receiveve each others datagram.
Quantum1024 is offline   Reply With Quote
Old 03-26-2005, 05:41 AM   #3
Registered User
 
Join Date: Dec 2004
Posts: 95
To the first question:

You don't need external synchronization just to send() and recv() in multiple threads on the same socket, but you'll likely sync. some at some point.
azteched is offline   Reply With Quote
Old 03-26-2005, 11:53 AM   #4
Registered User
 
Mortissus's Avatar
 
Join Date: Dec 2004
Location: Brazil, Porto Alegre
Posts: 152
Thanks for the answer!

I will try to better explain the second question. Is UDP safe against collision (physical level)? I need to know what kind of errors can I have with UDP, that I do not have with TCP, besides datagrams dropped and arriving out of order. What I must consider when programming UDP, that I do not need to worry with TCP.

As always, thanks any kind of help.
Mortissus is offline   Reply With Quote
Old 03-26-2005, 12:19 PM   #5
Registered User
 
Join Date: Jan 2005
Posts: 847
Other then datagrams ariving out of order and being dropped they can be corupted or duplicated.
If both hosts send a datagram they wont collide, the router(s) will still foreward both allthoug neither is guaranteed to arive and each host may not receive the others datagram at EXACLY the same time.
Quantum1024 is offline   Reply With Quote
Old 03-27-2005, 08:57 PM   #6
Registered User
 
Mortissus's Avatar
 
Join Date: Dec 2004
Location: Brazil, Porto Alegre
Posts: 152
Ok! Thanks very much!
Mortissus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with UDP AlexS C# Programming 0 07-07-2009 06:21 PM
simultaneously waiting for data on FIFO and UDP using select call yogesh3073 Networking/Device Communication 2 01-05-2007 09:53 AM
C++ Builder UDP programming Hankyaku Networking/Device Communication 5 09-17-2005 08:41 AM
Traceroute using UDP and ICMP Unregistered C++ Programming 1 08-09-2002 07:09 PM
Traceroute using UDP + ICMP Unregistered Windows Programming 0 08-05-2002 10:50 AM


All times are GMT -6. The time now is 06:05 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22