-
Notifications
You must be signed in to change notification settings - Fork 1
/
SocketServer.h
44 lines (31 loc) · 1 KB
/
SocketServer.h
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
//
// SocketServer.h
//
// Created by Søren Bruus Frank on 13/04/14.
// Copyright (c) 2014 Bruus Frank. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SocketConnection.h"
@class SocketServer;
@protocol SocketServerDelegate
// Server has been terminated because of an error
- (void) serverFailed:(SocketServer *)server reason:(NSString*)reason;
// Server has accepted a new connection and it needs to be processed
- (void) handleNewConnection:(SocketConnection*)connection;
@end
typedef enum {
CFSocket = 0,
POSIXSocket = 1
} socketType;
@interface SocketServer : NSObject <NSNetServiceDelegate>
@property (nonatomic, strong) NSNetService *service;
@property (nonatomic, assign) CFSocketRef cfSocket;
@property (nonatomic, assign) uint16_t port;
@property (nonatomic, strong) id<SocketServerDelegate> delegate;
- (SocketServer *)init;
- (SocketServer *)initWithSocketType:(socketType)socketType;
- (BOOL)start;
- (void)terminate;
- (BOOL)publishService;
- (void)unpublishService;
@end