// 初始化socket
self.asyncUdpSocket = [[AsyncUdpSocket alloc] initWithDelegate:self];
NSError *error = nil;
// 设置超时
[self.asyncUdpSocket receiveWithTimeout:3000 tag:0];
[self.asyncUdpSocket enableBroadcast:YES error:&error];
// 发送广播
<pre name="code" class="objc"> NSString *str = @"discoverySN";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
[self.asyncUdpSocket sendData:data toHost:@"255.255.255.255" port:5000 withTimeout:3000 tag:1];
// 不要设置下面这行代码,会出现<span style="font-family: Arial, Helvetica, sans-serif;">CFSocketSetAddress listen failure: 102提示,并且还会收