Differences From Artifact [5e012e3410]:
- File src/OFTCPSocket.m — part of check-in [3b97fc3cd9] at 2014-01-04 00:24:08 on branch trunk — Update copyright. (user: js, size: 17735) [annotate] [blame] [check-ins using]
To Artifact [367b0cdd47]:
- File
src/OFTCPSocket.m
— part of check-in
[e54c8c0368]
at
2014-01-16 23:38:42
on branch trunk
— Add +[OFString nativeOSEncoding].
This replaces OF_STRING_ENCODING_NATIVE, as a define was not flexible
enough (determining the native OS encoding at startup was not possible). (user: js, size: 17417) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
361 362 363 364 365 366 367 | memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICSERV; snprintf(portCString, 7, "%" PRIu16, port); | < | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICSERV; snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host UTF8String], portCString, &hints, &res0)) @throw [OFAddressTranslationFailedException exceptionWithHost: host socket: self]; for (res = res0; res != NULL; res = res->ai_next) { if ((_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == INVALID_SOCKET) |
︙ | ︙ | |||
395 396 397 398 399 400 401 | OFDataArray *addrlist; # endif memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = OF_BSWAP16_IF_LE(port); | | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | OFDataArray *addrlist; # endif memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = OF_BSWAP16_IF_LE(port); if ((addr.sin_addr.s_addr = inet_addr([host UTF8String])) != (in_addr_t)(-1)) { if ((_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { @throw [OFConnectionFailedException exceptionWithHost: host port: port socket: self]; } |
︙ | ︙ | |||
427 428 429 430 431 432 433 | } # ifdef OF_HAVE_THREADS addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)]; [mutex lock]; # endif | | < | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | } # ifdef OF_HAVE_THREADS addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)]; [mutex lock]; # endif if ((he = gethostbyname([host UTF8String])) == NULL) { # ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithHost: host socket: self]; |
︙ | ︙ | |||
572 573 574 575 576 577 578 | memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE; snprintf(portCString, 7, "%" PRIu16, port); | < | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE; snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host UTF8String], portCString, &hints, &res)) @throw [OFAddressTranslationFailedException exceptionWithHost: host socket: self]; if ((_socket = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host |
︙ | ︙ | |||
603 604 605 606 607 608 609 | freeaddrinfo(res); #else memset(&addr, 0, sizeof(addr)); addr.in.sin_family = AF_INET; addr.in.sin_port = OF_BSWAP16_IF_LE(port); | | | | < | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | freeaddrinfo(res); #else memset(&addr, 0, sizeof(addr)); addr.in.sin_family = AF_INET; addr.in.sin_port = OF_BSWAP16_IF_LE(port); if ((addr.in.sin_addr.s_addr = inet_addr([host UTF8String])) == (in_addr_t)(-1)) { # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct hostent *he; if ((he = gethostbyname([host UTF8String])) == NULL) @throw [OFAddressTranslationFailedException exceptionWithHost: host socket: self]; if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { @throw [OFAddressTranslationFailedException |
︙ | ︙ | |||
758 759 760 761 762 763 764 | @try { if (getnameinfo((struct sockaddr*)_sockAddr, _sockAddrLen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV)) @throw [OFAddressTranslationFailedException exceptionWithSocket: self]; | | < | < | 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | @try { if (getnameinfo((struct sockaddr*)_sockAddr, _sockAddrLen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV)) @throw [OFAddressTranslationFailedException exceptionWithSocket: self]; return [OFString stringWithUTF8String: host]; } @finally { [self freeMemory: host]; } #else # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif host = inet_ntoa(((struct sockaddr_in*)_sockAddr)->sin_addr); if (host == NULL) @throw [OFAddressTranslationFailedException exceptionWithSocket: self]; return [OFString stringWithUTF8String: host]; # ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } # endif #endif |
︙ | ︙ |