@@ -140,15 +140,15 @@ { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif - if (_socket != INVALID_SOCKET) + if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if ((_socket = socket(address->sockaddr.sockaddr.sa_family, - SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) { + SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) { *errNo = OFSocketErrNo(); return false; } #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) @@ -160,11 +160,11 @@ } - (bool)of_connectSocketToAddress: (const OFSocketAddress *)address errNo: (int *)errNo { - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; /* Cast needed for AmigaOS, where the argument is declared non-const */ if (connect(_socket, (struct sockaddr *)&address->sockaddr.sockaddr, address->length) != 0) { @@ -176,11 +176,11 @@ } - (void)of_closeSocket { closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; } - (void)connectToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); @@ -220,11 +220,11 @@ runLoopMode: (OFRunLoopMode)runLoopMode { void *pool = objc_autoreleasePoolPush(); id delegate; - if (_socket != INVALID_SOCKET) + if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) { delegate = [[[OFTCPSocketSOCKS5Connector alloc] initWithSocket: self @@ -268,11 +268,11 @@ block: (OFTCPSocketAsyncConnectBlock)block { void *pool = objc_autoreleasePoolPush(); id delegate = nil; - if (_socket != INVALID_SOCKET) + if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) { delegate = [[[OFTCPSocketSOCKS5Connector alloc] initWithSocket: self @@ -304,11 +304,11 @@ OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif - if (_socket != INVALID_SOCKET) + if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; @@ -319,11 +319,11 @@ address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; OFSocketAddressSetPort(&address, port); if ((_socket = socket(address.sockaddr.sockaddr.sa_family, - SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) + SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: OFSocketErrNo()]; @@ -344,11 +344,11 @@ if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; @@ -372,11 +372,11 @@ if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self @@ -398,11 +398,11 @@ if (OFGetSockName(_socket, &address.sockaddr.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; @@ -414,20 +414,20 @@ else if (address.sockaddr.sockaddr.sa_family == AF_INET6) return OFFromBigEndian16(address.sockaddr.in6.sin6_port); # endif else { closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #else closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EADDRNOTAVAIL]; #endif