I am trying to get a program for iPhone running on the simulator. My problem is with receiving UDP data. I use asyncUdpSocket. If I make a socket and use sendData:(NSD
I'm new with Objective C (so bear with my ignorance of it), but I have been able to get AsyncUdpSocketDelegate to receive, for the most part. A few things to try/confirm:
Make sure the self
class that you are initializing as your socket delegate is the class that you're expecting the callbacks on.
Make sure your class adopts the AsyncUdpSocketDelegate
protocol. I'm not sure if this is actually necessary, but it couldn't hurt. In your class header, looks like:
@interface |your class| : |super class| <|Other protocol(s)|, AsyncUdpSocketDelegate> {
Make sure you have your delegate methods declared in your interface and implementation. The method signature should look like this:
- (BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port;
Try calling receiveWithTimeout
with a non-zero timeout value. May give you different results.
Use Wireshark to make sure you are in fact receiving UDP data when and where you think you are. I'm not trying to insult your intelligence, but I've spent quite a while trying to track down network code bugs in the past when the issue was actually my network configuration.