ObjFW  Diff

Differences From Artifact [855c7eb790]:

To Artifact [349339a041]:


60
61
62
63
64
65
66
67


68
69
70
71
72
73
74
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
75







-
+
+








Class of_tls_socket_class = Nil;

static of_run_loop_mode_t connectRunLoopMode = @"of_tcp_socket_connect_mode";
static OFString *defaultSOCKS5Host = nil;
static uint16_t defaultSOCKS5Port = 1080;

@interface OFTCPSocket_AsyncConnectContext: OFObject <OFTCPSocketDelegate>
@interface OFTCPSocket_AsyncConnectContext: OFObject <OFTCPSocketDelegate,
    OFTCPSocketDelegate_Private>
{
	OFTCPSocket *_socket;
	OFString *_host;
	uint16_t _port;
	OFString *_SOCKS5Host;
	uint16_t _SOCKS5Port;
	id <OFTCPSocketDelegate> _delegate;
102
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







-
-







			  host: (OFString *)host
			  port: (uint16_t)port
		    SOCKS5Host: (OFString *)SOCKS5Host
		    SOCKS5Port: (uint16_t)SOCKS5Port
			 block: (of_tcp_socket_async_connect_block_t)block;
#endif
- (void)didConnect;
- (void)socketDidConnect: (OFTCPSocket *)sock
	       exception: (id)exception;
- (void)tryNextAddressWithRunLoopMode: (of_run_loop_mode_t)runLoopMode;
-	(void)resolver: (OFDNSResolver *)resolver
  didResolveDomainName: (OFString *)domainName
       socketAddresses: (OFData *)socketAddresses
	       context: (id)context
	     exception: (id)exception;
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode;
228
229
230
231
232
233
234
235
236


237
238
239
240
241
242
243
227
228
229
230
231
232
233


234
235
236
237
238
239
240
241
242







-
-
+
+







							     port: _port];
		}
#ifdef OF_HAVE_BLOCKS
	}
#endif
}

- (void)socketDidConnect: (OFTCPSocket *)sock
	       exception: (id)exception
- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))sock
		  exception: (id)exception
{
	if (exception != nil) {
		if (_socketAddressesIndex >= [_socketAddresses count]) {
			_exception = [exception retain];
			[self didConnect];
		} else {
			[self tryNextAddressWithRunLoopMode:
281
282
283
284
285
286
287
288
289
290
291
292

293
294
295
296
297
298
299
300
280
281
282
283
284
285
286


287
288

289

290
291
292
293
294
295
296







-
-


-
+
-







	}

	[_socket setBlocking: false];

	if (![_socket of_connectSocketToAddress: &address
					  errNo: &errNo]) {
		if (errNo == EINPROGRESS) {
			SEL selector = @selector(socketDidConnect:exception:);

			[OFRunLoop of_addAsyncConnectForTCPSocket: _socket
							     mode: runLoopMode
							   target: self
							 delegate: self];
							 selector: selector];
			return;
		} else {
			[_socket of_closeSocket];

			if (_socketAddressesIndex >= [_socketAddresses count]) {
				_exception = [[OFConnectionFailedException
				    alloc] initWithHost: _host