ObjFW  Diff

Differences From Artifact [d0efc140d4]:

To Artifact [2ff5fb89f7]:


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

	isListening = YES;
}

- (OFTCPSocket*)accept
{
	OFTCPSocket *newSocket;
	struct sockaddr *addr;
	socklen_t addrLen;
	int newSock;

	newSocket = [[[isa alloc] init] autorelease];
	addrLen = sizeof(struct sockaddr);

	@try {
		addr = [newSocket allocMemoryWithSize: sizeof(struct sockaddr)];
	} @catch (id e) {
		[newSocket release];
		@throw e;
	}

	if ((newSock = accept(sock, addr, &addrLen)) == INVALID_SOCKET) {

		[newSocket release];
		@throw [OFAcceptFailedException newWithClass: isa
						      socket: self];
	}

	newSocket->sock = newSock;
	newSocket->sockAddr = addr;







|













|
>







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

	isListening = YES;
}

- (OFTCPSocket*)accept
{
	OFTCPSocket *newSocket;
	struct sockaddr_storage *addr;
	socklen_t addrLen;
	int newSock;

	newSocket = [[[isa alloc] init] autorelease];
	addrLen = sizeof(struct sockaddr);

	@try {
		addr = [newSocket allocMemoryWithSize: sizeof(struct sockaddr)];
	} @catch (id e) {
		[newSocket release];
		@throw e;
	}

	if ((newSock = accept(sock, (struct sockaddr*)addr,
	    &addrLen)) == INVALID_SOCKET) {
		[newSocket release];
		@throw [OFAcceptFailedException newWithClass: isa
						      socket: self];
	}

	newSocket->sock = newSock;
	newSocket->sockAddr = addr;
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	host = [self allocMemoryWithSize: NI_MAXHOST];

	@try {
		if (getnameinfo(sockAddr, sockAddrLen, host, NI_MAXHOST, NULL,
		    0, NI_NUMERICHOST))
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa];

		return [OFString stringWithCString: host];
	} @finally {
		[self freeMemory: host];
	}







|
|







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	host = [self allocMemoryWithSize: NI_MAXHOST];

	@try {
		if (getnameinfo((struct sockaddr*)sockAddr, sockAddrLen, host,
		    NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa];

		return [OFString stringWithCString: host];
	} @finally {
		[self freeMemory: host];
	}