459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
objc_autoreleasePoolPop(pool);
}
#endif
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} addr;
socklen_t addrLen;
|
>
|
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
|
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 (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
freeaddrinfo(res);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
|
>
>
>
>
>
|
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
|
[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 (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
|
>
>
>
>
>
|
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
|