109
110
111
112
113
114
115
116
117
118
119
120
121
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
153
|
109
110
111
112
113
114
115
116
117
118
119
120
121
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
|
-
+
-
-
+
-
-
+
-
|
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode
{
of_socket_address_t address =
of_socket_address_ipx(_node, _network, _port);
id exception = nil;
int errNo;
if (![_socket of_createSocketForAddress: &address
if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
exception = [self of_connectionFailedExceptionForErrNo: errNo];
goto inform_delegate;
}
_socket.canBlock = false;
if (![_socket of_connectSocketToAddress: &address
if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
if (errNo == EINPROGRESS) {
[OFRunLoop of_addAsyncConnectForSocket: _socket
mode: runLoopMode
delegate: self];
return;
}
[_socket of_closeSocket];
exception = [self of_connectionFailedExceptionForErrNo: errNo];
}
inform_delegate:
[self performSelector: @selector(of_socketDidConnect:exception:)
withObject: _socket
withObject: exception
afterDelay: 0];
}
- (void)of_socketDidConnect: (id)sock
- (void)of_socketDidConnect: (id)sock exception: (id)exception
exception: (id)exception
{
id <OFSPXStreamSocketDelegate> delegate =
((OFSPXStreamSocket *)sock).delegate;
if (exception == nil)
((OFSPXStreamSocket *)sock).canBlock = true;
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
-
+
-
-
+
-
|
network: (uint32_t)network
port: (uint16_t)port
{
of_socket_address_t address =
of_socket_address_ipx(node, network, port);
int errNo;
if (![self of_createSocketForAddress: &address
if (![self of_createSocketForAddress: &address errNo: &errNo])
errNo: &errNo])
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
errNo: errNo];
if (![self of_connectSocketToAddress: &address
if (![self of_connectSocketToAddress: &address errNo: &errNo]) {
errNo: &errNo]) {
[self of_closeSocket];
@throw [OFConnectionFailedException
exceptionWithNode: node
network: network
port: port
socket: self
|