How to find out the sender's ip address of a udp packet that was received on a device running iOS 3.2 or higher?
For example, if using Python on a computer, I'd use SocketServer.UDPServer
which takes a subclass of SocketServer.BaseRequestHandler
which defines the handle
callback. When a packet arrives, the callback is called and the sender's ip address would be in self.client_address
, where self
is the SocketServer.BaseRequestHandler
instance.
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.
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.