Overview
Context
Changes
Modified src/OFStreamSocket.m
from [ae35beffef]
to [60c85e14ca].
︙ | | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
+
+
|
- (size_t)_readNBytes: (size_t)size
intoBuffer: (char*)buf
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
@throw [OFNotConnectedException newWithClass: isa
socket: self];
if (eos) {
OFReadFailedException *e;
e = [OFReadFailedException newWithClass: isa
requestedSize: size];
#ifndef _WIN32
|
︙ | | |
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
+
+
|
- (size_t)_writeNBytes: (size_t)size
fromBuffer: (const char*)buf
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
@throw [OFNotConnectedException newWithClass: isa
socket: self];
if (eos) {
OFWriteFailedException *e;
e = [OFWriteFailedException newWithClass: isa
requestedSize: size];
#ifndef _WIN32
|
︙ | | |
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
-
+
+
+
+
+
+
+
+
+
+
|
{
return sock;
}
- (void)close
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
@throw [OFNotConnectedException newWithClass: isa
socket: self];
close(sock);
sock = INVALID_SOCKET;
eos = NO;
listening = NO;
}
- (void)dealloc
{
if (sock != INVALID_SOCKET)
[self close];
[super dealloc];
}
@end
|
Modified src/OFTCPSocket.m
from [2b016c1ada]
to [c2279eed1e].
︙ | | |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
+
+
+
|
return self;
}
- (void)connectToHost: (OFString*)host
onPort: (uint16_t)port
{
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException newWithClass: isa];
@throw [OFAlreadyConnectedException newWithClass: isa
socket: self];
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res, *res0;
char port_s[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(port_s, 7, "%" PRIu16, port);
if (getaddrinfo([host cString], port_s, &hints, &res0))
@throw [OFAddressTranslationFailedException newWithClass: isa
socket: self
host: host];
for (res = res0; res != NULL; res = res->ai_next) {
if ((sock = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) == INVALID_SOCKET)
continue;
|
︙ | | |
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
+
|
if (he->h_addrtype != AF_INET ||
(sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFConnectionFailedException newWithClass: isa
socket: self
host: host
port: port];
}
# ifdef OF_THREADS
@try {
for (ip = he->h_addr_list; *ip != NULL; ip++)
|
︙ | | |
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
+
-
+
+
+
+
+
|
close(sock);
sock = INVALID_SOCKET;
}
#endif
if (sock == INVALID_SOCKET)
@throw [OFConnectionFailedException newWithClass: isa
socket: self
host: host
port: port];
}
- (void)bindToPort: (uint16_t)port
onHost: (OFString*)host
{
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException newWithClass: isa];
@throw [OFAlreadyConnectedException newWithClass: isa
socket: self];
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res;
char port_s[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(port_s, 7, "%" PRIu16, port);
if (getaddrinfo([host cString], port_s, &hints, &res))
@throw [OFAddressTranslationFailedException newWithClass: isa
socket: self
host: host];
if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException newWithClass: isa
socket: self
host: host
port: port];
if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
freeaddrinfo(res);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException newWithClass: isa
socket: self
host: host
port: port];
}
freeaddrinfo(res);
#else
struct hostent *he;
|
︙ | | |
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
-
+
+
+
-
+
+
+
|
}
#endif
}
- (void)listenWithBackLog: (int)backlog
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
@throw [OFNotConnectedException newWithClass: isa
socket: self];
if (listen(sock, backlog) == -1)
@throw [OFListenFailedException newWithClass: isa
socket: self
backLog: backlog];
listening = YES;
}
- (void)listen
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
@throw [OFNotConnectedException newWithClass: isa
socket: self];
if (listen(sock, 5) == -1)
@throw [OFListenFailedException newWithClass: isa
socket: self
backLog: 5];
listening = YES;
}
- (OFTCPSocket*)accept
{
|
︙ | | |
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
-
+
+
|
} @catch (id e) {
[newsock release];
@throw e;
}
if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) {
[newsock release];
@throw [OFAcceptFailedException newWithClass: isa];
@throw [OFAcceptFailedException newWithClass: isa
socket: self];
}
newsock->sock = s;
newsock->sockAddr = addr;
newsock->sockAddrLen = addrlen;
return newsock;
|
︙ | | |
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
396
397
398
399
400
401
402
403
|
-
-
-
-
-
-
-
-
|
{
[super close];
[self freeMemory: sockAddr];
sockAddr = NULL;
sockAddrLen = 0;
}
- (void)dealloc
{
if (sock != INVALID_SOCKET)
[self close];
[super dealloc];
}
@end
|
Modified src/exceptions/OFAcceptFailedException.h
from [ce027c17fd]
to [104989e573].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating that accepting a connection failed.
*/
@interface OFAcceptFailedException: OFException
{
OFTCPSocket *socket;
int errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
@property (readonly) int errNo;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not accept a connection
* \return A new accept failed exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket;
/**
* Initializes an already allocated accept failed exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not accept a connection
* \return An initialized accept failed exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket;
/**
* \return The socket which could not accept a connection
*/
- (OFTCPSocket*)socket;
/**
* \return The errno from when the exception was created
*/
- (int)errNo;
@end
|
Modified src/exceptions/OFAcceptFailedException.m
from [f69e0d7d77]
to [12e9aaa538].
︙ | | |
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
|
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
66
67
68
69
70
71
72
73
74
75
76
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#import "OFAcceptFailedException.h"
#import "OFString.h"
#import "common.h"
@implementation OFAcceptFailedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
{
return [[self alloc] initWithClass: class_
socket: socket];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
errNo = GET_SOCK_ERRNO;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"Failed to accept connection in socket of type %@! " ERRFMT,
inClass, ERRPARAM];
return description;
}
- (OFTCPSocket*)socket
{
return socket;
}
- (int)errNo
{
return errNo;
}
@end
|
Modified src/exceptions/OFAddressTranslationFailedException.h
from [fbf7c7443e]
to [0ed93ff62f].
︙ | | |
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
|
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
66
67
68
69
70
71
72
73
|
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating the translation of an address failed.
*/
@interface OFAddressTranslationFailedException: OFException
{
OFTCPSocket *socket;
OFString *host;
int errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
@property (readonly, nonatomic) OFString *host;
@property (readonly) int errNo;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not translate the address
* \param host The host for which translation was requested
* \return A new address translation failed exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host;
/**
* Initializes an already allocated address translation failed exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not translate the address
* \param host The host for which translation was requested
* \return An initialized address translation failed exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host;
/**
* \return The errno from when the exception was created
* \return The socket which could not translate the address
*/
- (int)errNo;
- (OFTCPSocket*)socket;
/**
* /return The host for which translation was requested
*/
- (OFString*)host;
/**
* \return The errno from when the exception was created
*/
- (int)errNo;
@end
|
Modified src/exceptions/OFAddressTranslationFailedException.m
from [5d7fbf9d94]
to [169c6cd7e2].
︙ | | |
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
|
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
66
67
68
69
70
|
+
+
+
+
+
|
#import "OFAddressTranslationFailedException.h"
#import "OFString.h"
#import "common.h"
@implementation OFAddressTranslationFailedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
{
return [[self alloc] initWithClass: class_
socket: socket
host: host];
}
- initWithClass: (Class)class_
{
self = [super initWithClass: class_];
errNo = GET_AT_ERRNO;
return self;
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
host: (OFString*)host_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
host = [host_ copy];
errNo = GET_AT_ERRNO;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[host release];
[super dealloc];
}
- (OFString*)description
{
|
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
-
+
-
+
+
+
+
+
+
|
description = [[OFString alloc] initWithFormat:
@"An address translation failed in class %@! " ERRFMT,
inClass, AT_ERRPARAM];
return description;
}
- (int)errNo
- (OFTCPSocket*)socket
{
return errNo;
return socket;
}
- (OFString*)host
{
return host;
}
- (int)errNo
{
return errNo;
}
@end
|
Modified src/exceptions/OFAlreadyConnectedException.h
from [86f0bbf938]
to [15e72a820b].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating an attempt to connect or bind an already
* connected or bound socket.
*/
@interface OFAlreadyConnectedException: OFException
{
OFTCPSocket *socket;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which is already connected
* \return A new already connected exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket;
/**
* Initializes an already allocated already connected exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which is already connected
* \return An initialized already connected exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket;
/**
* \return The socket which is already connected
*/
- (OFTCPSocket*)socket;
@end
|
Modified src/exceptions/OFAlreadyConnectedException.m
from [fa4dcbbebe]
to [865fb79629].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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
66
67
68
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#include "config.h"
#import "OFAlreadyConnectedException.h"
#import "OFString.h"
@implementation OFAlreadyConnectedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
{
return [[self alloc] initWithClass: class_
socket: socket];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"The socket of type %@ is already connected or bound and thus "
@"can't be connected or bound again!", inClass];
return description;
}
- (OFTCPSocket*)socket
{
return socket;
}
@end
|
Modified src/exceptions/OFBindFailedException.h
from [bf8fd546ce]
to [e567d3a7b8].
︙ | | |
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
66
67
68
69
70
71
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating that binding a socket failed.
*/
@interface OFBindFailedException: OFException
{
OFTCPSocket *socket;
OFString *host;
uint16_t port;
int errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
@property (readonly, nonatomic) OFString *host;
@property (readonly) uint16_t port;
@property (readonly) int errNo;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not be bound
* \param host The host on which binding failed
* \param port The port on which binding failed
* \return A new bind failed exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port;
/**
* Initializes an already allocated bind failed exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not be bound
* \param host The host on which binding failed
* \param port The port on which binding failed
* \return An initialized bind failed exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port;
/**
* \return The errno from when the exception was created
* \return The socket which could not be bound
*/
- (int)errNo;
- (OFTCPSocket*)socket;
/**
* \return The host on which binding failed
*/
- (OFString*)host;
/**
* \return The port on which binding failed
*/
- (uint16_t)port;
/**
* \return The errno from when the exception was created
*/
- (int)errNo;
@end
|
Modified src/exceptions/OFBindFailedException.m
from [7d666e8245]
to [618c1f8bd7].
︙ | | |
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
#import "OFNotImplementedException.h"
#import "common.h"
@implementation OFBindFailedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port
{
return [[self alloc] initWithClass: class_
socket: socket
host: host
port: port];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException newWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
host: (OFString*)host_
port: (uint16_t)port_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
host = [host_ copy];
port = port_;
errNo = GET_SOCK_ERRNO;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[host release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"Binding to port %" @PRIu16 @" on host %@ failed in class %@! "
ERRFMT, port, host, inClass, ERRPARAM];
return description;
}
- (int)errNo
- (OFTCPSocket*)socket
{
return errNo;
return socket;
}
- (OFString*)host
{
return host;
}
- (uint16_t)port
{
return port;
}
- (int)errNo
{
return errNo;
}
@end
|
Modified src/exceptions/OFConnectionFailedException.h
from [b8d2821451]
to [97e9485df5].
︙ | | |
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
66
67
68
69
70
71
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating that a connection could not be established.
*/
@interface OFConnectionFailedException: OFException
{
OFTCPSocket *socket;
OFString *host;
uint16_t port;
int errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
@property (readonly, nonatomic) OFString *host;
@property (readonly) uint16_t port;
@property (readonly) int errNo;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not connect
* \param host The host to which the connection failed
* \param port The port on the host to which the connection failed
* \return A new connection failed exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port;
/**
* Initializes an already allocated connection failed exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which could not connect
* \param host The host to which the connection failed
* \param port The port on the host to which the connection failed
* \return An initialized connection failed exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port;
/**
* \return The errno from when the exception was created
* \return The socket which could not connect
*/
- (int)errNo;
- (OFTCPSocket*)socket;
/**
* \return The host to which the connection failed
*/
- (OFString*)host;
/**
* \return The port on the host to which the connection failed
*/
- (uint16_t)port;
/**
* \return The errno from when the exception was created
*/
- (int)errNo;
@end
|
Modified src/exceptions/OFConnectionFailedException.m
from [c3843b39a9]
to [5af8de549d].
︙ | | |
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
#import "OFNotImplementedException.h"
#import "common.h"
@implementation OFConnectionFailedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
host: (OFString*)host
port: (uint16_t)port
{
return [[self alloc] initWithClass: class_
socket: socket
host: host
port: port];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException newWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
host: (OFString*)host_
port: (uint16_t)port_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
host = [host_ copy];
port = port_;
errNo = GET_SOCK_ERRNO;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[host release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"A connection to %@ on port %" @PRIu16 @"could not be established "
@"in class %@! " ERRFMT, host, port, inClass, ERRPARAM];
return description;
}
- (int)errNo
- (OFTCPSocket*)socket
{
return errNo;
return socket;
}
- (OFString*)host
{
return host;
}
- (uint16_t)port
{
return port;
}
- (int)errNo
{
return errNo;
}
@end
|
Modified src/exceptions/OFListenFailedException.h
from [b05d0483ce]
to [4490777cf7].
︙ | | |
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
|
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
66
67
68
69
70
71
72
73
|
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFTCPSocket;
/**
* \brief An exception indicating that listening on the socket failed.
*/
@interface OFListenFailedException: OFException
{
OFTCPSocket *socket;
int backLog;
int errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFTCPSocket *socket;
@property (readonly) int backLog;
@property (readonly) int errNo;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which failed to listen
* \param backlog The requested size of the back log
* \return A new listen failed exception
*/
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
backLog: (int)backlog;
/**
* Initializes an already allocated listen failed exception
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which failed to listen
* \param backlog The requested size of the back log
* \return An initialized listen failed exception
*/
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket
backLog: (int)backlog;
/**
* \return The errno from when the exception was created
* \return The socket which failed to listen
*/
- (int)errNo;
- (OFTCPSocket*)socket;
/**
* \return The requested back log.
*/
- (int)backLog;
/**
* \return The errno from when the exception was created
*/
- (int)errNo;
@end
|
Modified src/exceptions/OFListenFailedException.m
from [da1ca346f6]
to [98f4572f60].
︙ | | |
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
66
67
68
69
70
71
72
73
74
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
|
#import "OFNotImplementedException.h"
#import "common.h"
@implementation OFListenFailedException
+ newWithClass: (Class)class_
socket: (OFTCPSocket*)socket
backLog: (int)backlog
{
return [[self alloc] initWithClass: class_
socket: socket
backLog: backlog];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException newWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
backLog: (int)backlog
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
backLog = backlog;
errNo = GET_SOCK_ERRNO;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"Failed to listen in socket of type %@ with a back log of %d! "
ERRFMT, inClass, backLog, ERRPARAM];
return description;
}
- (int)errNo
- (OFTCPSocket*)socket
{
return errNo;
return socket;
}
- (int)backLog
{
return backLog;
}
- (int)errNo
{
return errNo;
}
@end
|
Modified src/exceptions/OFNotConnectedException.h
from [01fc568575]
to [951b1065be].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
@class OFStreamSocket;
/**
* \brief An exception indicating a socket is not connected or bound.
*/
@interface OFNotConnectedException: OFException
{
OFStreamSocket *socket;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFStreamSocket *socket;
#endif
/**
* \param class_ The class of the object which caused the exception
* \param socket The socket which is not connected
* \return A new not connected exception
*/
+ newWithClass: (Class)class_
socket: (OFStreamSocket*)socket;
/**
* Initializes an already allocated not connected exception.
*
* \param class_ The class of the object which caused the exception
* \param socket The socket which is not connected
* \return An initialized not connected exception
*/
- initWithClass: (Class)class_
socket: (OFStreamSocket*)socket;
/**
* \return The socket which is not connected
*/
- (OFStreamSocket*)socket;
@end
|
Modified src/exceptions/OFNotConnectedException.m
from [0c3725a393]
to [25504636c1].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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
66
67
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#include "config.h"
#import "OFNotConnectedException.h"
#import "OFString.h"
@implementation OFNotConnectedException
+ newWithClass: (Class)class_
socket: (OFStreamSocket*)socket
{
return [[self alloc] initWithClass: class_
socket: socket];
}
- initWithClass: (Class)class_
socket: (OFStreamSocket*)socket_
{
self = [super initWithClass: class_];
@try {
socket = [socket_ retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[socket release];
[super dealloc];
}
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"The socket of type %@ is not connected or bound!", inClass];
return description;
}
- (OFStreamSocket*)socket
{
return socket;
}
@end
|