Overview
| Comment: | OFTCPSocket: Set SO_REUSEADDR on -[bind]. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
5243a863203be884857cb6fecfe73b26 |
| User & Date: | js on 2012-12-27 11:16:33 |
| Other Links: | manifest | tags |
Context
|
2012-12-27
| ||
| 11:20 | OFStreamObserver_kqueue: Return NO on error. (check-in: e5157b2ba2 user: js tags: trunk) | |
| 11:16 | OFTCPSocket: Set SO_REUSEADDR on -[bind]. (check-in: 5243a86320 user: js tags: trunk) | |
|
2012-12-26
| ||
| 20:55 | OFHTTPRequestResult -> OFHTTPRequestReply. (check-in: 75f187cef5 user: js tags: trunk) | |
Changes
Modified src/OFTCPSocket.m from [a9ec628526] to [22a93cdc38].
| ︙ | |||
459 460 461 462 463 464 465 466 467 468 469 470 471 472 | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | + |
objc_autoreleasePoolPop(pool);
}
#endif
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
const int one = 1;
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} addr;
socklen_t addrLen;
|
| ︙ | |||
497 498 499 500 501 502 503 504 505 506 507 508 509 510 | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | + + + + + |
host: host];
if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
freeaddrinfo(res);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
|
| ︙ | |||
551 552 553 554 555 556 557 558 559 560 561 562 563 564 | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | + + + + + |
[mutex unlock];
# endif
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
if (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
|
| ︙ |