@@ -71,11 +71,11 @@ if (self.class == [OFSequencedPacketSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; _canBlock = true; } @catch (id e) { [self release]; @throw e; } @@ -83,11 +83,11 @@ return self; } - (void)dealloc { - if (_socket != INVALID_SOCKET) + if (_socket != OFInvalidSocketHandle) [self close]; [super dealloc]; } @@ -150,11 +150,11 @@ - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException @@ -222,11 +222,11 @@ } #endif - (void)sendBuffer: (const void *)buffer length: (size_t)length { - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS ssize_t bytesWritten; @@ -302,11 +302,11 @@ [self listenWithBacklog: SOMAXCONN]; } - (void)listenWithBacklog: (int)backlog { - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (listen(_socket, backlog) == -1) @throw [OFListenFailedException exceptionWithSocket: self @@ -331,25 +331,26 @@ #if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC) if ((client->_socket = paccept(_socket, &client->_remoteAddress.sockaddr.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == - INVALID_SOCKET) + OFInvalidSocketHandle) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, &client->_remoteAddress.sockaddr.sockaddr, - &client->_remoteAddress.length, SOCK_CLOEXEC)) == INVALID_SOCKET) + &client->_remoteAddress.length, SOCK_CLOEXEC)) == + OFInvalidSocketHandle) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; #else if ((client->_socket = accept(_socket, &client->_remoteAddress.sockaddr.sockaddr, - &client->_remoteAddress.length)) == INVALID_SOCKET) + &client->_remoteAddress.length)) == OFInvalidSocketHandle) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: OFSocketErrNo()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) @@ -413,11 +414,11 @@ } #endif - (const OFSocketAddress *)remoteAddress { - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (_remoteAddress.length == 0) @throw [OFInvalidArgumentException exception]; @@ -436,11 +437,11 @@ - (int)fileDescriptorForReading { #ifndef OF_WINDOWS return _socket; #else - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) return -1; if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -451,11 +452,11 @@ - (int)fileDescriptorForWriting { #ifndef OF_WINDOWS return _socket; #else - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) return -1; if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -463,15 +464,15 @@ #endif } - (void)close { - if (_socket == INVALID_SOCKET) + if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; _listening = false; memset(&_remoteAddress, 0, sizeof(_remoteAddress)); closesocket(_socket); - _socket = INVALID_SOCKET; + _socket = OFInvalidSocketHandle; } @end