-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathKMSListener.h
More file actions
65 lines (43 loc) · 1.33 KB
/
KMSListener.h
File metadata and controls
65 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Created by Sam Deane on 06/11/2012.
// Copyright 2012 Karelia Software. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
Object which listens on a given socket and executes a block
when an incoming connection is received.
*/
@interface KMSListener : NSObject
/**
Block which is run when a connection happens.
*/
typedef BOOL (^ConnectionBlock)(int socket);
/**
The port we're listening on.
*/
@property (readonly, nonatomic) NSUInteger port;
/**
Returns a new listener object for a given port.
@param port The port to listen on. Passing zero here causes the system to allocate a port.
@param block The block to execute when a connection is received.
@return The new listener.
*/
+ (KMSListener*)listenerWithPort:(NSUInteger)port connectionBlock:(ConnectionBlock)block;
/**
Initialise a new listener object for a given port.
@param port The port to listen on. Passing zero here causes the system to allocate a port.
@param block The block to execute when a connection is received.
@return The new listener.
*/
- (id)initWithPort:(NSUInteger)port connectionBlock:(ConnectionBlock)block;
/**
Start listening.
@return YES if we manage to start ok.
*/
- (BOOL)start;
/**
Stop listening.
@param reason The reason we're stopping (used for logging only).
*/
- (void)stop:(NSString*)reason;
@end