Skip to content

pencilCool/UDPBroadcastListener

Repository files navigation

UDPBroadcastListener

CI Status Version License Platform

Example

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]];

Requirements

Installation

UDPBroadcastListener is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'UDPBroadcastListener'

Author

pencilCool, [email protected]

Test

用 python 执行 udp_broadcast.py 脚本可以用来在 localhost 内发送广播,默认端口号是 5555

License

UDPBroadcastListener is available under the MIT license. See the LICENSE file for more info.

About

a ios udp global listener base on CocoaAsyncSocket

Resources

License

Stars

Watchers

Forks

Packages

No packages published