title: How to identify sender's ip address of a udp packet received on iOS device?
body: <p>How to find out the sender's ip address of a udp packet that was received on a device running <code>iOS 3.2</code> or higher?</p>
  
  <p>For example, if using Python on a computer, I'd use <code>SocketServer.UDPServer</code> which takes a subclass of <code>SocketServer.BaseRequestHandler</code> which defines the <code>handle</code> callback.  When a packet arrives, the callback is called and the sender's ip address would be in <code>self.client_address</code>, where <code>self</code> is the <code>SocketServer.BaseRequestHandler</code> instance.</p>
  
  <p>Unfortunately, I don't know how to extract this information or gain access to the associated ip header when programming in Objective C and using the frameworks provided for iOS.</p>
  
  <p>Right now the only solution I have is to explicitly write the sender's ip on the body of the udp packet, but I'd rather not rely on the sender putting that information there if I don't have to.</p>