To run the example project, clone the repo, and run pod install
from the Example directory first.
API usage
@interface ADelegate:NSObject<GCDAsyncUdpSocketDelegate>
@end
@implementation ADelegate
- (void)udpSocket:(GCDAsyncUdpSocket *)sock
didReceiveData:(NSData *)data
fromAddress:(NSData *)address
withFilterContext:(id)filterContext {
NSLog(@"Adelegate");
}
@end
@interface BDelegate:NSObject<GCDAsyncUdpSocketDelegate>
@end
@implementation BDelegate
- (void)udpSocket:(GCDAsyncUdpSocket *)sock
didReceiveData:(NSData *)data
fromAddress:(NSData *)address
withFilterContext:(id)filterContext {
NSLog(@"Bdelegate");
}
@end
[[UDPBroadcastListener shared] addDelegate:[ADelegate new]];
[[UDPBroadcastListener shared] addDelegate:[BDelegate new]];
UDPBroadcastListener is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'UDPBroadcastListener'
pencilCool, [email protected]
用 python 执行 udp_broadcast.py 脚本可以用来在 localhost 内发送广播,默认端口号是 5555
UDPBroadcastListener is available under the MIT license. See the LICENSE file for more info.