我使用GCDAsyncUdpSocket,我可以送多播或正常的UDP数据包。 我收到正常的报文没有问题,但我不能从其他iOS设备上接收多播数据包。
要接收我使用:
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress: (NSData *)address withFilterContext:(id)filterContext
{ NSString *msg = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
NSString *host = nil;
uint16_t port = 0;
[GCDAsyncUdpSocket getHost:&host port:&port fromAddress:address];
if (msg)
{
NSLog(@"Message = %@, Adress = %@ %i",msg,host,port);
}
else
{
NSLog(@"Error converting received data into UTF-8 String");
}
}