Modified src/OFIPXSocket.h
from [270a469bc4]
to [3f2d188d81].
︙ | | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
+
|
* @brief Bind the socket to the specified network, node and port with the
* specified packet type.
*
* @param port The port (sometimes called socket number) to bind to. 0 means to
* pick one and return via the returned socket address.
* @param packetType The packet type to use on the socket
* @return The address on which this socket can be reached
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already bound
*/
- (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFIPXSocket.m
from [f0059481b5]
to [7c065986f3].
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
+
|
#endif
#import "OFIPXSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
@implementation OFIPXSocket
@dynamic delegate;
- (OFSocketAddress)bindToPort: (uint16_t)port packetType: (uint8_t)packetType
{
const unsigned char zeroNode[IPX_NODE_LEN] = { 0 };
|
︙ | | |
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
106
107
108
109
110
111
112
113
|
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
106
107
108
109
110
111
112
113
114
115
116
|
-
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
|
protocol = NSPROTO_IPX + packetType;
#else
_packetType = address.sockaddr.ipx.sipx_type = packetType;
#endif
if ((_socket = socket(address.sockaddr.ipx.sipx_family,
SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithPort: port
packetType: packetType
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: packetType
socket: self
errNo: errNo];
}
if (address.sockaddr.ipx.sipx_family != AF_IPX) {
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: packetType
socket: self
errNo: EAFNOSUPPORT];
exceptionWithPort: port
packetType: packetType
socket: self
errNo: EAFNOSUPPORT];
}
return address;
}
#ifndef OF_WINDOWS
- (void)sendBuffer: (const void *)buffer
|
︙ | | |
Modified src/OFSPXSocket.h
from [40e34f28e7]
to [7301372af3].
︙ | | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
-
+
|
/**
* @brief Bind the socket to the specified network, node and port.
*
* @param port The port (sometimes called socket number) to bind to. 0 means to
* pick one and return via the returned socket address.
* @return The address on which this socket can be reached
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (OFSocketAddress)bindToPort: (uint16_t)port;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFSPXSocket.m
from [63c27817f9]
to [3f35e5cfcb].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFSPXSocket.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
#import "OFConnectionFailedException.h"
#import "OFNotOpenException.h"
#ifndef NSPROTO_SPX
# define NSPROTO_SPX 0
#endif
|
︙ | | |
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
-
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
|
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
address = OFSocketAddressMakeIPX(0, zeroNode, port);
if ((_socket = socket(address.sockaddr.ipx.sipx_family,
SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) ==
OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
if (address.sockaddr.ipx.sipx_family != AF_IPX) {
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: EAFNOSUPPORT];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: EAFNOSUPPORT];
}
return address;
}
@end
|
Modified src/OFSPXStreamSocket.m
from [a588145b61]
to [f1965656ad].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFSPXStreamSocket.h"
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
#import "OFConnectionFailedException.h"
#import "OFNotOpenException.h"
#ifndef NSPROTO_SPX
# define NSPROTO_SPX 0
#endif
|
︙ | | |
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
-
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
|
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
address = OFSocketAddressMakeIPX(0, zeroNode, port);
if ((_socket = socket(address.sockaddr.ipx.sipx_family,
SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
if (address.sockaddr.ipx.sipx_family != AF_IPX) {
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: EAFNOSUPPORT];
exceptionWithPort: port
packetType: SPXPacketType
socket: self
errNo: EAFNOSUPPORT];
}
return address;
}
@end
|
Modified src/OFTCPSocket.h
from [13742bc171]
to [5b7d6c5295].
︙ | | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
-
+
|
* @brief Binds the socket to the specified host and port.
*
* @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for
* IPv6 to bind to all.
* @param port The port to bind to. If the port is 0, an unused port will be
* chosen, which can be obtained using the return value.
* @return The port the socket was bound to
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFTCPSocket.m
from [3962a70e27]
to [f494d07225].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
-
+
|
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFString.h"
#import "OFTCPSocketSOCKS5Connector.h"
#import "OFThread.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
#import "OFGetOptionFailedException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFSetOptionFailedException.h"
static const OFRunLoopMode connectRunLoopMode =
@"OFTCPSocketConnectRunLoopMode";
|
︙ | | |
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
-
+
|
address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0];
OFSocketAddressSetPort(&address, port);
if ((_socket = socket(
((struct sockaddr *)&address.sockaddr)->sa_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: host
port: port
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
|
︙ | | |
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
+
-
-
-
-
+
+
+
+
|
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
} else {
for (;;) {
uint16_t rnd = 0;
int ret;
|
︙ | | |
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
-
+
|
if (OFSocketErrNo() != EADDRINUSE) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
}
}
|
︙ | | |
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
|
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
@throw [OFBindSocketFailedException exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
switch (((struct sockaddr *)&address.sockaddr)->sa_family) {
case AF_INET:
return OFFromBigEndian16(address.sockaddr.in.sin_port);
# ifdef OF_HAVE_IPV6
case AF_INET6:
return OFFromBigEndian16(address.sockaddr.in6.sin6_port);
# endif
default:
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindSocketFailedException
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: EAFNOSUPPORT];
exceptionWithHost: host
port: port
socket: self
errNo: EAFNOSUPPORT];
}
#else
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException exceptionWithHost: host
port: port
socket: self
errNo: EADDRNOTAVAIL];
@throw [OFBindSocketFailedException exceptionWithHost: host
port: port
socket: self
errNo: EADDRNOTAVAIL];
#endif
}
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
- (void)setSendsKeepAlives: (bool)sendsKeepAlives
{
int v = sendsKeepAlives;
|
︙ | | |
Modified src/OFUDPSocket.h
from [e94e3865e1]
to [9064e55448].
︙ | | |
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
-
+
|
* @brief Binds the socket to the specified host and port.
*
* @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for
* IPv6 to bind to all.
* @param port The port to bind to. If the port is 0, an unused port will be
* chosen, which can be obtained using the return value.
* @return The port the socket was bound to
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already bound
*/
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFUDPSocket.m
from [61fa5cfa02]
to [080326bc21].
︙ | | |
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
|
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
|
-
+
-
+
|
#import "OFDNSResolver.h"
#import "OFData.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFThread.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
@implementation OFUDPSocket
@dynamic delegate;
- (uint16_t)of_bindToAddress: (OFSocketAddress *)address
extraType: (int)extraType OF_DIRECT
{
void *pool = objc_autoreleasePoolPush();
uint16_t port;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
int flags;
#endif
if ((_socket = socket(
((struct sockaddr *)&address->sockaddr)->sa_family,
SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressPort(address)
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
|
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
-
+
|
if (bind(_socket, (struct sockaddr *)&address->sockaddr,
address->length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressPort(address)
socket: self
errNo: errNo];
}
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
} else {
|
︙ | | |
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
-
+
|
int errNo = OFSocketErrNo();
OFString *host = OFSocketAddressString(address);
port = OFSocketAddressPort(address);
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
}
}
|
︙ | | |
129
130
131
132
133
134
135
136
137
138
139
140
141
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
167
168
169
170
171
|
129
130
131
132
133
134
135
136
137
138
139
140
141
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
167
168
169
170
171
|
-
+
-
+
-
+
|
if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr,
&address->length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressPort(address)
socket: self
errNo: errNo];
}
switch (((struct sockaddr *)&address->sockaddr)->sa_family) {
case AF_INET:
return OFFromBigEndian16(address->sockaddr.in.sin_port);
# ifdef OF_HAVE_IPV6
case AF_INET6:
return OFFromBigEndian16(address->sockaddr.in6.sin6_port);
# endif
default:
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressPort(address)
socket: self
errNo: EAFNOSUPPORT];
}
#else
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressPort(address)
socket: self
errNo: EADDRNOTAVAIL];
#endif
}
|
︙ | | |
Modified src/OFUNIXDatagramSocket.h
from [342ce1dbb2]
to [a2c9620021].
︙ | | |
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-
+
|
id <OFUNIXDatagramSocketDelegate> delegate;
/**
* @brief Bind the socket to the specified path.
*
* @param path The path to bind to
* @return The address on which this socket can be reached
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already bound
*/
- (OFSocketAddress)bindToPath: (OFString *)path;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFUNIXDatagramSocket.m
from [2b20715dbe]
to [45b8d937e9].
︙ | | |
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
|
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
|
-
+
-
+
-
-
-
+
+
+
|
#import "OFUNIXDatagramSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFString.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
@implementation OFUNIXDatagramSocket
@dynamic delegate;
- (OFSocketAddress)bindToPath: (OFString *)path
{
OFSocketAddress address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
int flags;
#endif
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
address = OFSocketAddressMakeUNIX(path);
if ((_socket = socket(address.sockaddr.un.sun_family,
SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithPath: path
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException exceptionWithPath: path
socket: self
errNo: errNo];
@throw [OFBindSocketFailedException exceptionWithPath: path
socket: self
errNo: errNo];
}
return address;
}
@end
|
Modified src/OFUNIXStreamSocket.h
from [8a5717e58d]
to [b908fbf9aa].
︙ | | |
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
|
*/
- (void)connectToPath: (OFString *)path;
/**
* @brief Binds the socket to the specified host and port.
*
* @param path The path to bind to
* @throw OFBindFailedException Binding failed
* @throw OFBindSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (void)bindToPath: (OFString *)path;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFUNIXStreamSocket.m
from [70b73d6c70]
to [af5f7ae84f].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
|
#import "OFUNIXStreamSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFString.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
#import "OFConnectionFailedException.h"
@implementation OFUNIXStreamSocket
@dynamic delegate;
- (void)connectToPath: (OFString *)path
{
|
︙ | | |
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
107
108
109
110
111
|
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
107
108
109
110
111
|
-
+
-
-
-
+
+
+
|
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
address = OFSocketAddressMakeUNIX(path);
if ((_socket = socket(address.sockaddr.un.sun_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFBindFailedException
@throw [OFBindSocketFailedException
exceptionWithPath: path
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindFailedException exceptionWithPath: path
socket: self
errNo: errNo];
@throw [OFBindSocketFailedException exceptionWithPath: path
socket: self
errNo: errNo];
}
}
@end
|
Modified src/ObjFW.h
from [4cea05be8a]
to [8b8202fcd3].
︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
+
|
#endif
#import "OFAllocFailedException.h"
#import "OFException.h"
#ifdef OF_HAVE_SOCKETS
# import "OFAcceptFailedException.h"
# import "OFAlreadyConnectedException.h"
# import "OFBindFailedException.h"
# import "OFBindSocketFailedException.h"
#endif
#import "OFChangeCurrentDirectoryFailedException.h"
#import "OFChecksumMismatchException.h"
#ifdef OF_HAVE_THREADS
# import "OFConditionBroadcastFailedException.h"
# import "OFConditionSignalFailedException.h"
# import "OFConditionStillWaitingException.h"
|
︙ | | |
Modified src/exceptions/Makefile
from [a8a6570db6]
to [d91b9a06b1].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-
+
|
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS}
SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \
OFGetCurrentDirectoryFailedException.m
SRCS_PLUGINS = OFLoadPluginFailedException.m
SRCS_SOCKETS = OFAcceptFailedException.m \
OFAlreadyConnectedException.m \
OFBindFailedException.m \
OFBindSocketFailedException.m \
OFConnectionFailedException.m \
OFDNSQueryFailedException.m \
OFHTTPRequestFailedException.m \
OFListenFailedException.m \
OFObserveKernelEventsFailedException.m \
OFResolveHostFailedException.m \
OFTLSHandshakeFailedException.m
|
︙ | | |
Renamed and modified
src/exceptions/OFBindFailedException.h
[9447c1c83e]
to src/exceptions/OFBindSocketFailedException.h
[27f2ca0058].
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
+
|
#endif
#import "OFSocket.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFBindFailedException \
* OFBindFailedException.h ObjFW/OFBindFailedException.h
* @class OFBindSocketFailedException \
* OFBindSocketFailedException.h ObjFW/OFBindSocketFailedException.h
*
* @brief An exception indicating that binding a socket failed.
*/
@interface OFBindFailedException: OFException
@interface OFBindSocketFailedException: OFException
{
/* IP */
OFString *_Nullable _host;
uint16_t _port;
/* IPX */
uint8_t _packetType;
/* UNIX socket */
OFString *_Nullable _path;
id _socket;
int _errNo;
OF_RESERVE_IVARS(OFBindFailedException, 4)
OF_RESERVE_IVARS(OFBindSocketFailedException, 4)
}
/**
* @brief The host on which binding failed.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *host;
|
︙ | | |
Renamed and modified
src/exceptions/OFBindFailedException.m
[0fa4a1273c]
to src/exceptions/OFBindSocketFailedException.m
[e3360ae495].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
-
+
|
* 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.
*/
#include "config.h"
#import "OFBindFailedException.h"
#import "OFBindSocketFailedException.h"
#import "OFString.h"
@implementation OFBindFailedException
@implementation OFBindSocketFailedException
@synthesize host = _host, port = _port, packetType = _packetType, path = _path;
@synthesize socket = _socket, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
Modified tests/OFIPXSocketTests.m
from [4dd5afc6b6]
to [e80e3e99da].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
|
char buffer[5];
TEST(@"+[socket]", (sock = [OFIPXSocket socket]))
@try {
TEST(@"-[bindToPort:packetType:]",
R(address1 = [sock bindToPort: 0 packetType: 0]))
} @catch (OFBindFailedException *e) {
} @catch (OFBindSocketFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFIPXSocket] -[bindToPort:packetType:]: "
@"IPX unsupported, skipping tests"];
break;
|
︙ | | |
Modified tests/OFSPXSocketTests.m
from [c95d72f728]
to [8c56b24eef].
︙ | | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
-
+
|
TEST(@"+[socket]", (sockClient = [OFSPXSocket socket]) &&
(sockServer = [OFSPXSocket socket]))
@try {
TEST(@"-[bindToPort:]",
R(address1 = [sockServer bindToPort: 0]))
} @catch (OFBindFailedException *e) {
} @catch (OFBindSocketFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFSPXSocket] -[bindToPort:]: "
@"IPX unsupported, skipping tests"];
break;
|
︙ | | |
Modified tests/OFSPXStreamSocketTests.m
from [af4ba0ff2c]
to [1b61f46c13].
︙ | | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
-
+
|
TEST(@"+[socket]", (sockClient = [OFSPXStreamSocket socket]) &&
(sockServer = [OFSPXStreamSocket socket]))
@try {
TEST(@"-[bindToPort:]",
R(address1 = [sockServer bindToPort: 0]))
} @catch (OFBindFailedException *e) {
} @catch (OFBindSocketFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFSPXStreamSocket] -[bindToPort:]: "
@"IPX unsupported, skipping tests"];
break;
|
︙ | | |
Modified tests/OFUNIXDatagramSocketTests.m
from [54df3210f6]
to [61f9f2c60c].
︙ | | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
+
|
[[OFUUID UUID] UUIDString]];
#endif
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
@try {
TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))
} @catch (OFBindFailedException *e) {
} @catch (OFBindSocketFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
case EPERM:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFUNIXDatagramSocket] -[bindToPath:]: "
@"UNIX datagram sockets unsupported, skipping "
|
︙ | | |
Modified tests/OFUNIXStreamSocketTests.m
from [72ce4faa3f]
to [cebf3c029f].
︙ | | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
+
|
#endif
TEST(@"+[socket]", (sockClient = [OFUNIXStreamSocket socket]) &&
(sockServer = [OFUNIXStreamSocket socket]))
@try {
TEST(@"-[bindToPath:]", R([sockServer bindToPath: path]))
} @catch (OFBindFailedException *e) {
} @catch (OFBindSocketFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
case EPERM:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFUNIXStreamSocket] -[bindToPath:]: "
@"UNIX stream sockets unsupported, skipping tests"];
|
︙ | | |