ObjFW  Diff

Differences From Artifact [742dd6ce2f]:

To Artifact [5920a82404]:


211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225







-
+







				  port: _port];
	} @catch (OFException *e) {
		_exception = [[e retain] autorelease];
	}

	[self performSelector: @selector(didConnect)
		     onThread: _sourceThread
		waitUntilDone: NO];
		waitUntilDone: false];

	objc_autoreleasePoolPop(pool);

	return nil;
}
@end
#endif
277
278
279
280
281
282
283
284

285
286
287
288
289

290
291
292
293
294
295
296
277
278
279
280
281
282
283

284
285
286
287
288

289
290
291
292
293
294
295
296







-
+




-
+







	[_SOCKS5Host release];

	[super dealloc];
}

- (void)setSOCKS5Host: (OFString*)SOCKS5Host
{
	OF_SETTER(_SOCKS5Host, SOCKS5Host, YES, 1)
	OF_SETTER(_SOCKS5Host, SOCKS5Host, true, 1)
}

- (OFString*)SOCKS5Host
{
	OF_GETTER(_SOCKS5Host, YES)
	OF_GETTER(_SOCKS5Host, true)
}

- (void)setSOCKS5Port: (uint16_t)SOCKS5Port
{
	_SOCKS5Port = SOCKS5Port;
}

345
346
347
348
349
350
351
352

353
354
355
356
357
358
359
345
346
347
348
349
350
351

352
353
354
355
356
357
358
359







-
+







		}

		break;
	}

	freeaddrinfo(res0);
#else
	BOOL connected = NO;
	bool connected = false;
	struct hostent *he;
	struct sockaddr_in addr;
	char **ip;
# ifdef OF_HAVE_THREADS
	OFDataArray *addrlist;

	addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)];
409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
409
410
411
412
413
414
415

416
417
418
419
420
421
422
423







-
+







# endif
		memcpy(&addr.sin_addr.s_addr, *ip, he->h_length);

		if (connect(_socket, (struct sockaddr*)&addr,
		    sizeof(addr)) == -1)
			continue;

		connected = YES;
		connected = true;
		break;
	}

# ifdef OF_HAVE_THREADS
	[addrlist release];
# endif

631
632
633
634
635
636
637
638

639
640
641
642
643
644
645
631
632
633
634
635
636
637

638
639
640
641
642
643
644
645







-
+







							    socket: self];

	if (listen(_socket, backLog) == -1)
		@throw [OFListenFailedException exceptionWithClass: [self class]
							    socket: self
							   backLog: backLog];

	_listening = YES;
	_listening = true;
}

- (void)listen
{
	[self listenWithBackLog: SOMAXCONN];
}

678
679
680
681
682
683
684
685

686
687
688
689
690
691
692
678
679
680
681
682
683
684

685
686
687
688
689
690
691
692







-
+







- (void)asyncAcceptWithBlock: (of_tcpsocket_async_accept_block_t)block
{
	[OFRunLoop OF_addAsyncAcceptForTCPSocket: self
					   block: block];
}
#endif

- (void)setKeepAlivesEnabled: (BOOL)enable
- (void)setKeepAlivesEnabled: (bool)enable
{
	int v = enable;

	if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
		@throw [OFSetOptionFailedException
		    exceptionWithClass: [self class]
				stream: self];
736
737
738
739
740
741
742
743

744
745
746
747
748
749
750
751
752

753
754
755
756
757
736
737
738
739
740
741
742

743
744
745
746
747
748
749
750
751

752
753
754
755
756
757







-
+








-
+





# endif
#endif

	/* Get rid of a warning, never reached anyway */
	assert(0);
}

- (BOOL)isListening
- (bool)isListening
{
	return _listening;
}

- (void)close
{
	[super close];

	_listening = NO;
	_listening = false;
	[self freeMemory: _sockAddr];
	_sockAddr = NULL;
	_sockAddrLen = 0;
}
@end