Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CylonGlitch

macrumors 68030
Original poster
Jul 7, 2009
2,956
268
Nashville
Anyone have a decent example of doing UDP networking? I have been trying to get this all up and running but have been struggling with it. I understand the UDP interface, but how to establish the connection, I'm not getting it.
 
In what programming language?

And UDP doesn't have connections, at least not in the sense that TCP does. UDP sends a datagram to a target consisting of an IP address and port number. No "connection" is involved.
 
In what programming language?

And UDP doesn't have connections, at least not in the sense that TCP does. UDP sends a datagram to a target consisting of an IP address and port number. No "connection" is involved.

Right, there are no sockets per say; but there is the virtual connection between the two devices because they are expecting packets between the two. This is done in XCode3 and Objective-C.
 
Basically you readfrom() on the receiver and sendto() on the sender.

You must handle everything else manually as UDP does not guarantee the order of packets in the same way as TCP does. You also need to handle lost packets as UDP does not ensure that packets actually reach there destination.

I don't know if Apple have any nice Cocoa wrappers for UDP networking but I have a feeling they don't. If that is so then you need to read up on BSD sockets and look at the C API man pages for the functions I posted above. That should give you a decent starting point to work from.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.