UDP Networking

Discussion in 'Mac Programming' started by CylonGlitch, Oct 19, 2009.

  1. macrumors 68030

    CylonGlitch

    Joined:
    Jul 7, 2009
    Location:
    SoCal
    #1
    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.
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    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.
     
  3. thread starter macrumors 68030

    CylonGlitch

    Joined:
    Jul 7, 2009
    Location:
    SoCal
    #3
    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.
     
  4. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    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.
     
  5. macrumors 603

    Joined:
    Aug 9, 2009
    #5
  6. thread starter macrumors 68030

    CylonGlitch

    Joined:
    Jul 7, 2009
    Location:
    SoCal
    #6
    THANKS! This is exactly what I was looking for! :D
     

Share This Page