Overview
Context
Changes
Modified src/OFIPSocketAsyncConnector.m
from [964b049ea4]
to [11edaa9dd3].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
+
|
#import "OFIPSocketAsyncConnector.h"
#import "OFData.h"
#import "OFTCPSocket.h"
#import "OFThread.h"
#import "OFTimer.h"
#import "OFConnectSocketFailedException.h"
#import "OFConnectIPSocketFailedException.h"
#import "OFInvalidFormatException.h"
@implementation OFIPSocketAsyncConnector
- (instancetype)initWithSocket: (id)sock
host: (OFString *)host
port: (uint16_t)port
delegate: (id)delegate
|
︙ | | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
-
-
-
-
+
+
+
+
-
+
|
}
[self didConnect];
}
- (id)of_connectionFailedExceptionForErrNo: (int)errNo
{
return [OFConnectSocketFailedException exceptionWithHost: _host
port: _port
socket: _socket
errNo: errNo];
return [OFConnectIPSocketFailedException exceptionWithHost: _host
port: _port
socket: _socket
errNo: errNo];
}
- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode
{
OFSocketAddress address = *(const OFSocketAddress *)
[_socketAddresses itemAtIndex: _socketAddressesIndex++];
int errNo;
OFSocketAddressSetPort(&address, _port);
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectSocketFailedException alloc]
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
return;
}
|
︙ | | |
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
-
+
|
delegate: self];
return;
} else {
#endif
[_socket of_closeSocket];
if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectSocketFailedException
_exception = [[OFConnectIPSocketFailedException
alloc] initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
return;
}
|
︙ | | |
Modified src/OFSPXSocket.h
from [7047954772]
to [62171025db].
︙ | | |
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
-
+
|
/**
* @brief Connect the OFSPXSocket to the specified destination.
*
* @param network The network on which the node to connect to is
* @param node The node to connect to
* @param port The port (sometimes also called socket number) on the node to
* connect to
* @throw OFConnectSocketFailedException Connecting failed
* @throw OFConnectSPXSocketFailedException Connecting failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (void)connectToNetwork: (uint32_t)network
node: (const unsigned char [_Nonnull IPX_NODE_LEN])node
port: (uint16_t)port;
/**
|
︙ | | |
Modified src/OFSPXSocket.m
from [f57aab987d]
to [4bb1b2f501].
︙ | | |
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 "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindIPXSocketFailedException.h"
#import "OFConnectSocketFailedException.h"
#import "OFConnectSPXSocketFailedException.h"
#import "OFNotOpenException.h"
#ifndef NSPROTO_SPX
# define NSPROTO_SPX 0
#endif
static const uint8_t SPXPacketType = 5;
|
︙ | | |
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
-
-
-
-
-
+
+
+
+
+
|
#ifdef OF_HAVE_BLOCKS
}
#endif
}
- (id)of_connectionFailedExceptionForErrNo: (int)errNo
{
return [OFConnectSocketFailedException exceptionWithNetwork: _network
node: _node
port: _port
socket: _socket
errNo: errNo];
return [OFConnectSPXSocketFailedException exceptionWithNetwork: _network
node: _node
port: _port
socket: _socket
errNo: errNo];
}
@end
@implementation OFSPXSocket
@dynamic delegate;
- (int)of_createSocketForAddress: (const OFSocketAddress *)address
|
︙ | | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
-
+
-
+
|
node: (const unsigned char [IPX_NODE_LEN])node
port: (uint16_t)port
{
OFSocketAddress address = OFSocketAddressMakeIPX(network, node, port);
int errNo;
if (![self of_createSocketForAddress: &address errNo: &errNo])
@throw [OFConnectSocketFailedException
@throw [OFConnectSPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
socket: self
errNo: errNo];
if (![self of_connectSocketToAddress: &address errNo: &errNo]) {
[self of_closeSocket];
@throw [OFConnectSocketFailedException
@throw [OFConnectSPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
socket: self
errNo: errNo];
}
}
|
︙ | | |
Modified src/OFSPXStreamSocket.h
from [5118ed386d]
to [454aa9fc7f].
︙ | | |
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
-
+
|
/**
* @brief Connect the OFSPXStreamSocket to the specified destination.
*
* @param network The network on which the node to connect to is
* @param node The node to connect to
* @param port The port (sometimes also called socket number) on the node to
* connect to
* @throw OFConnectSocketFailedException Connecting failed
* @throw OFConnectSPXSocketFailedException Connecting failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (void)connectToNetwork: (uint32_t)network
node: (const unsigned char [_Nonnull IPX_NODE_LEN])node
port: (uint16_t)port;
/**
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
-
+
|
*
* @param network The IPX network to bind to. 0 means the current network.
* @param node The IPX network to bind to. An all zero node means the
* computer's node.
* @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 OFConnectSocketFailedException Binding failed
* @throw OFBindIPXSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (OFSocketAddress)
bindToNetwork: (uint32_t)network
node: (const unsigned char [_Nonnull IPX_NODE_LEN])node
port: (uint16_t)port;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFSPXStreamSocket.m
from [0a64a8186a]
to [3d76de2dbb].
︙ | | |
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 "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindIPXSocketFailedException.h"
#import "OFConnectSocketFailedException.h"
#import "OFConnectSPXSocketFailedException.h"
#import "OFNotOpenException.h"
#ifndef NSPROTO_SPX
# define NSPROTO_SPX 0
#endif
static const uint8_t SPXPacketType = 5;
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
-
-
-
-
-
+
+
+
+
+
|
#ifdef OF_HAVE_BLOCKS
}
#endif
}
- (id)of_connectionFailedExceptionForErrNo: (int)errNo
{
return [OFConnectSocketFailedException exceptionWithNetwork: _network
node: _node
port: _port
socket: _socket
errNo: errNo];
return [OFConnectSPXSocketFailedException exceptionWithNetwork: _network
node: _node
port: _port
socket: _socket
errNo: errNo];
}
@end
@implementation OFSPXStreamSocket
@dynamic delegate;
- (int)of_createSocketForAddress: (const OFSocketAddress *)address
|
︙ | | |
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
-
+
-
+
|
node: (const unsigned char [IPX_NODE_LEN])node
port: (uint16_t)port
{
OFSocketAddress address = OFSocketAddressMakeIPX(network, node, port);
int errNo;
if (![self of_createSocketForAddress: &address errNo: &errNo])
@throw [OFConnectSocketFailedException
@throw [OFConnectSPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
socket: self
errNo: errNo];
if (![self of_connectSocketToAddress: &address errNo: &errNo]) {
[self of_closeSocket];
@throw [OFConnectSocketFailedException
@throw [OFConnectSPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
socket: self
errNo: errNo];
}
}
|
︙ | | |
Modified src/OFTCPSocket.h
from [cc82674b9e]
to [522e53453c].
︙ | | |
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
-
+
|
+ (uint16_t)SOCKS5Port;
/**
* @brief Connects the OFTCPSocket to the specified destination.
*
* @param host The host to connect to
* @param port The port on the host to connect to
* @throw OFConnectSocketFailedException Connecting failed
* @throw OFConnectIPSocketFailedException Connecting failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (void)connectToHost: (OFString *)host port: (uint16_t)port;
/**
* @brief Asynchronously connects the OFTCPSocket to the specified destination.
*
|
︙ | | |
Modified src/OFTCPSocketSOCKS5Connector.m
from [5536c6da5c]
to [f6cfb53e62].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
+
|
#include <errno.h>
#import "OFTCPSocketSOCKS5Connector.h"
#import "OFData.h"
#import "OFRunLoop.h"
#import "OFString.h"
#import "OFConnectSocketFailedException.h"
#import "OFConnectIPSocketFailedException.h"
enum {
stateSendAuthentication = 1,
stateReadVersion,
stateSendRequest,
stateReadResponse,
stateReadAddress,
|
︙ | | |
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
-
+
|
runLoopMode = [OFRunLoop currentRunLoop].currentMode;
switch (_SOCKS5State) {
case stateReadVersion:
SOCKSVersion = buffer;
if (SOCKSVersion[0] != 5 || SOCKSVersion[1] != 0) {
_exception = [[OFConnectSocketFailedException alloc]
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: self
errNo: EPROTONOSUPPORT];
[self didConnect];
return false;
}
|
︙ | | |
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
-
+
|
_SOCKS5State = stateSendRequest;
[_socket asyncWriteData: _request runLoopMode: runLoopMode];
return false;
case stateReadResponse:
response = buffer;
if (response[0] != 5 || response[2] != 0) {
_exception = [[OFConnectSocketFailedException alloc]
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: self
errNo: EPROTONOSUPPORT];
[self didConnect];
return false;
}
|
︙ | | |
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
-
+
|
errNo = EPROTO;
#else
errNo = 0;
#endif
break;
}
_exception = [[OFConnectSocketFailedException alloc]
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: _socket
errNo: errNo];
[self didConnect];
return false;
}
|
︙ | | |
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
-
+
|
case 4: /* IPv6 */
_SOCKS5State = stateReadAddress;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 16 + 2
runLoopMode: runLoopMode];
return false;
default:
_exception = [[OFConnectSocketFailedException alloc]
_exception = [[OFConnectIPSocketFailedException alloc]
initWithHost: _host
port: _port
socket: self
errNo: EPROTONOSUPPORT];
[self didConnect];
return false;
}
|
︙ | | |
Modified src/OFUNIXStreamSocket.h
from [fd1fe5978d]
to [3d105f3c9b].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
+
|
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
id <OFUNIXStreamSocketDelegate> delegate;
/**
* @brief Connects the OFUNIXStreamSocket to the specified destination.
*
* @param path The path to connect to
* @throw OFConnectSocketFailedException Connecting failed
* @throw OFConnectUNIXSocketFailedException Connecting failed
* @throw OFAlreadyConnectedException The socket is already connected or bound
*/
- (void)connectToPath: (OFString *)path;
/**
* @brief Binds the socket to the specified host and port.
*
|
︙ | | |
Modified src/OFUNIXStreamSocket.m
from [5f6af41045]
to [ff26304fa1].
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
#import "OFUNIXStreamSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFString.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindUNIXSocketFailedException.h"
#import "OFConnectSocketFailedException.h"
#import "OFConnectUNIXSocketFailedException.h"
@implementation OFUNIXStreamSocket
@dynamic delegate;
- (void)connectToPath: (OFString *)path
{
OFSocketAddress address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && 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_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFConnectSocketFailedException
@throw [OFConnectUNIXSocketFailedException
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 (connect(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFConnectSocketFailedException
@throw [OFConnectUNIXSocketFailedException
exceptionWithPath: path
socket: self
errNo: errNo];
}
}
- (void)bindToPath: (OFString *)path
|
︙ | | |
Modified src/ObjFW.h
from [f33758b828]
to [8723793ddc].
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
+
+
+
+
+
+
+
|
# import "OFConditionBroadcastFailedException.h"
# import "OFConditionSignalFailedException.h"
# import "OFConditionStillWaitingException.h"
# import "OFConditionWaitFailedException.h"
#endif
#ifdef OF_HAVE_SOCKETS
# import "OFConnectSocketFailedException.h"
# import "OFConnectIPSocketFailedException.h"
# ifdef OF_HAVE_UNIX_SOCKETS
# import "OFConnectUNIXSocketFailedException.h"
# endif
# ifdef OF_HAVE_IPX
# import "OFConnectSPXSocketFailedException.h"
# endif
#endif
#import "OFCopyItemFailedException.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
#ifdef OF_WINDOWS
# import "OFCreateWindowsRegistryKeyFailedException.h"
#endif
|
︙ | | |
Modified src/exceptions/Makefile
from [449638fc56]
to [3ffa6b7f15].
︙ | | |
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
|
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
|
+
-
+
-
-
+
+
+
+
|
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS}
SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \
OFGetCurrentDirectoryFailedException.m
SRCS_PLUGINS = OFLoadPluginFailedException.m
SRCS_SOCKETS = OFAcceptSocketFailedException.m \
OFAlreadyConnectedException.m \
OFBindIPSocketFailedException.m \
OFBindSocketFailedException.m \
OFBindIPSocketFailedException.m \
OFConnectIPSocketFailedException.m \
OFConnectSocketFailedException.m \
OFDNSQueryFailedException.m \
OFHTTPRequestFailedException.m \
OFListenFailedException.m \
OFObserveKernelEventsFailedException.m \
OFResolveHostFailedException.m \
OFTLSHandshakeFailedException.m \
${USE_SRCS_IPX} \
${USE_SRCS_UNIX_SOCKETS}
SRCS_IPX = OFBindIPXSocketFailedException.m
SRCS_UNIX_SOCKETS = OFBindUNIXSocketFailedException.m
SRCS_IPX = OFBindIPXSocketFailedException.m \
OFConnectSPXSocketFailedException.m
SRCS_UNIX_SOCKETS = OFBindUNIXSocketFailedException.m \
OFConnectUNIXSocketFailedException.m
SRCS_THREADS = OFConditionBroadcastFailedException.m \
OFConditionSignalFailedException.m \
OFConditionStillWaitingException.m \
OFConditionWaitFailedException.m \
OFThreadJoinFailedException.m \
OFThreadStartFailedException.m \
OFThreadStillRunningException.m
|
︙ | | |
Modified src/exceptions/OFAcceptSocketFailedException.m
from [da410bacce]
to [701680e6d7].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
@synthesize socket = _socket, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo
+ (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo
{
return [[[self alloc] initWithSocket: socket errNo: errNo] autorelease];
return [[[self alloc] initWithSocket: sock errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSocket: (id)socket errNo: (int)errNo
- (instancetype)initWithSocket: (id)sock errNo: (int)errNo
{
self = [super init];
_socket = [socket retain];
_socket = [sock retain];
_errNo = errNo;
return self;
}
- (void)dealloc
{
|
︙ | | |
Modified src/exceptions/OFAlreadyConnectedException.m
from [055eee0622]
to [9abd285501].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
#import "OFAlreadyConnectedException.h"
#import "OFString.h"
@implementation OFAlreadyConnectedException
@synthesize socket = _socket;
+ (instancetype)exceptionWithSocket: (id)socket
+ (instancetype)exceptionWithSocket: (id)sock
{
return [[[self alloc] initWithSocket: socket] autorelease];
return [[[self alloc] initWithSocket: sock] autorelease];
}
- (instancetype)init
{
return [self initWithSocket: nil];
}
- (instancetype)initWithSocket: (id)socket
- (instancetype)initWithSocket: (id)sock
{
self = [super init];
_socket = [socket retain];
_socket = [sock retain];
return self;
}
- (void)dealloc
{
[_socket release];
|
︙ | | |
Added src/exceptions/OFConnectIPSocketFailedException.h version [f85ab38f4c].
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* 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 "OFConnectSocketFailedException.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFConnectIPSocketFailedException \
* OFConnectIPSocketFailedException.h \
* ObjFW/OFConnectIPSocketFailedException.h
*
* @brief An exception indicating that an IP connection could not be
* established.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFConnectIPSocketFailedException: OFConnectSocketFailedException
{
OFString *_Nullable _host;
uint16_t _port;
}
/**
* @brief The host to which the connection failed.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *host;
/**
* @brief The port on the host to which the connection failed.
*/
@property (readonly, nonatomic) uint16_t port;
/**
* @brief Creates a new, autoreleased connect IP socket failed exception.
*
* @param host The host to which the connection failed
* @param port The port on the host to which the connection failed
* @param socket The socket which could not connect
* @param errNo The errno of the error that occurred
* @return A new, autoreleased connect IP socket failed exception
*/
+ (instancetype)exceptionWithHost: (OFString *)host
port: (uint16_t)port
socket: (id)socket
errNo: (int)errNo;
+ (instancetype)exceptionWithSocket: (id)socket
errNo: (int)errNo OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated connect IP socket failed exception.
*
* @param host The host to which the connection failed
* @param port The port on the host to which the connection failed
* @param socket The socket which could not connect
* @param errNo The errno of the error that occurred
* @return An initialized connect IP socket failed exception
*/
- (instancetype)initWithHost: (OFString *)host
port: (uint16_t)port
socket: (id)socket
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/exceptions/OFConnectIPSocketFailedException.m version [b9f4e412ce].
|
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
66
67
68
69
70
71
72
73
74
75
76
77
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* 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 "OFConnectIPSocketFailedException.h"
#import "OFString.h"
@implementation OFConnectIPSocketFailedException
@synthesize host = _host, port = _port;
+ (instancetype)exceptionWithSocket: (id)sock errNo: (int)errNo
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithHost: (OFString *)host
port: (uint16_t)port
socket: (id)sock
errNo: (int)errNo
{
return [[[self alloc] initWithHost: host
port: port
socket: sock
errNo: errNo] autorelease];
}
- (instancetype)initWithSocket: (id)sock errNo: (int)errNo
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithHost: (OFString *)host
port: (uint16_t)port
socket: (id)sock
errNo: (int)errNo
{
self = [super initWithSocket: sock errNo: errNo];
@try {
_host = [host copy];
_port = port;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_host release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"A connection to %@ on port %" @PRIu16 @" could not be "
@"established in socket of type %@: %@",
_host, _port, [_socket class], OFStrError(_errNo)];
}
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/exceptions/OFConnectSPXSocketFailedException.h version [acdfa9213b].