Wuyx
2017-01-04 0ba5a82e9ec833aa36729dfbad7deffbf3ea05c6
commit | author | age
6e1425 1 #import <Foundation/Foundation.h>
H 2
3 @class wax_server;
4
5 extern NSString * const TCPServerErrorDomain;
6
7 typedef enum {
8     kTCPServerCouldNotBindToIPv4Address = 1,
9     kTCPServerCouldNotBindToIPv6Address = 2,
10     kTCPServerNoSocketsAvailable = 3,
11 } TCPServerErrorCode;
12
13
14 @protocol WaxServerDelegate
15
16 @optional
17 - (void)connected;
18 - (void)disconnected;
19 - (void)dataReceived:(NSData *)data;
20
21 @end
22
23
24 @interface wax_server : NSObject <NSStreamDelegate, NSNetServiceDelegate> {    
25     CFSocketRef _ipv4socket;
26     id<WaxServerDelegate> _delegate;
27
28     NSNetService *_netService;
29     NSInputStream *_inStream;
30     NSOutputStream *_outStream;
31 }
32     
33 @property(nonatomic, assign) id<WaxServerDelegate> delegate;
34
35 - (NSError *)startOnPort:(NSUInteger)port;
36 - (BOOL)stop;
37 - (BOOL)enableBonjourOnPort:(NSUInteger)port;
38 - (void)disableBonjour;
39
40 - (BOOL)send:(NSString *)output;
41 - (void)receive:(NSData *)output;
42
43 @end
44
45 // This is needed because the runtime doesn't automatically load protocols
46 @interface HACK_WAX_DELEGATE_IMPLEMENTOR : NSObject  <WaxServerDelegate> {}
47 @end