AsyncUdpSocket *socket=[[AsyncUdpSocket alloc]initWithDelegate:self];
NSTimeInterval timeout=500;
NSString *[email protected]"quick_stat";
NSData *data=[NSData dataWithData:[request dataUsingEncoding:NSASCIIStringEncoding] ];
UInt16 port=8081;
[socket sendData :data toHost:@"255.255.255.255" port:port withTimeout:timeout tag:1];
NSLog(@"begin scan");
如果主機地址是 「255.255.255.255」,或 「192.168.1.255」,將得到iPhone SDK是否限制udp廣播?
2011-03-30 19:40:34.547 VOCO [38177:207] AsyncUdpSocket 0x629bf30接收意外CFSocketCallBackType 8 。 2011-03-30 19:40:34.549 voco [38177:207] Error Domain = NSPOSIXErrorDomain Code = 13「Permission denied」UserInfo = 0x62b4360 {NSLocalizedDescription = Permission denied} 2011-03-30 19:40:34.550 voco [38177:207]不發送
如果主機地址是「255.255.255.0」或「192.168.0.255」將得到
begin scan
2011-03-30 19:35:48.415 VOCO [37930:207] AsyncUdpSocket 0x565fea0收到意外CFSocketCallBackType 8. 2011-03-30 19:35:48.417 VOCO [37930:207]發送
所以我猜不是我的代碼造成的。我該如何解決它?
通過添加[socket enableBroadcast:YES error:error]修復; – atu0830 2011-03-31 04:07:37