Overview
| Comment: | Use sockaddr_storage instead of sockaddr in OFTCPSocket. This ensures it's big enough and correctly aligned. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | 0.5 |
| Files: | files | file ages | folders |
| SHA3-256: |
1688bf89e06f1e8e56372c48d8379a77 |
| User & Date: | js on 2011-07-17 02:08:27 |
| Other Links: | branch diff | manifest | tags |
Context
|
2011-07-17
| ||
| 02:11 | Include sys/types.h in of_asprintf.m. (check-in: e9768d31bb user: js tags: 0.5) | |
| 02:08 |
Use sockaddr_storage instead of sockaddr in OFTCPSocket. This ensures it's big enough and correctly aligned. (check-in: 1688bf89e0 user: js tags: 0.5) | |
| 01:55 | Define __NO_EXT_QNX in files using unistd.h or fcntl.h. (check-in: 59e52af26d user: js tags: 0.5) | |
Changes
Modified src/OFTCPSocket.h from [98f00d6f79] to [7f7c70792a].
| ︙ | ︙ | |||
33 34 35 36 37 38 39 |
*
* To connect to a server, create a socket and connect it.
* To create a server, create a socket, bind it and listen on it.
*/
@interface OFTCPSocket: OFStreamSocket
{
BOOL isListening;
| | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
*
* To connect to a server, create a socket and connect it.
* To create a server, create a socket, bind it and listen on it.
*/
@interface OFTCPSocket: OFStreamSocket
{
BOOL isListening;
struct sockaddr_storage *sockAddr;
socklen_t sockAddrLen;
}
/**
* Connect the OFTCPSocket to the specified destination.
*
* \param host The host to connect to
|
| ︙ | ︙ |
Modified src/OFTCPSocket.m from [5139608894] to [1ca1782d51].
| ︙ | ︙ | |||
347 348 349 350 351 352 353 |
isListening = YES;
}
- (OFTCPSocket*)accept
{
OFTCPSocket *newsock;
| | > | | 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 *newsock;
struct sockaddr_storage *addr;
socklen_t addrlen;
int s;
newsock = [[[isa alloc] init] autorelease];
addrlen = sizeof(struct sockaddr);
@try {
addr = [newsock allocMemoryWithSize: sizeof(struct sockaddr)];
} @catch (id e) {
[newsock release];
@throw e;
}
if ((s = accept(sock, (struct sockaddr*)addr,
&addrlen)) == INVALID_SOCKET) {
[newsock release];
@throw [OFAcceptFailedException newWithClass: isa
socket: self];
}
newsock->sock = s;
newsock->sockAddr = addr;
|
| ︙ | ︙ | |||
393 394 395 396 397 398 399 |
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
char *host = [self allocMemoryWithSize: NI_MAXHOST];
@try {
| | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
char *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];
}
|
| ︙ | ︙ |