void NamedPipeConnection::_close() { if( isClosed( )) return; LBASSERT( _fd > 0 ); if( isListening( )) { _exitAIOAccept(); if( _fd != INVALID_HANDLE_VALUE && !DisconnectNamedPipe( _fd )) LBERROR << "Could not disconnect named pipe: " << lunchbox::sysError << std::endl; } else { _exitAIORead(); if( _fd != INVALID_HANDLE_VALUE && !CloseHandle( _fd )) LBERROR << "Could not close named pipe: " << lunchbox::sysError << std::endl; } _fd = INVALID_HANDLE_VALUE; _setState( STATE_CLOSED ); }
void SocketConnection::_close() { if( isClosed( )) return; if( isListening( )) _exitAIOAccept(); else if( isConnected( )) _exitAIORead(); LBASSERT( _readFD > 0 ); #ifdef _WIN32 const bool closed = ( ::closesocket(_readFD) == 0 ); #else const bool closed = ( ::close(_readFD) == 0 ); #endif if( !closed ) LBWARN << "Could not close socket: " << lunchbox::sysError << std::endl; _readFD = INVALID_SOCKET; _writeFD = INVALID_SOCKET; _setState( STATE_CLOSED ); }
void PGMConnection::close() { if( _state == STATE_CLOSED ) return; _printReadStatistics(); _printSendStatistics(); if( isListening( )) _exitAIOAccept(); else if( isConnected( )) _exitAIORead(); _state = STATE_CLOSED; EQASSERT( _readFD > 0 ); if( _readFD > 0 ) { const std::string& iName = _description->getInterface(); if( !iName.empty( )) { unsigned long interface; if( !_parseHostname( iName, interface ) || ::setsockopt( _readFD, IPPROTO_RM, RM_DEL_RECEIVE_IF, (char*)&interface, sizeof(uint32_t)) == SOCKET_ERROR ) { EQWARN << "can't delete recv interface " << base::sysError << std::endl; } } #ifdef _WIN32 const bool closed = ( ::closesocket( _readFD ) == 0 ); #else const bool closed = ( ::close( _readFD ) == 0 ); #endif if( !closed ) EQWARN << "Could not close read socket: " << base::sysError << std::endl; } if( _writeFD > 0 && isListening( )) { #ifdef _WIN32 const bool closed = ( ::closesocket( _writeFD ) == 0 ); #else const bool closed = ( ::close( _writeFD ) == 0 ); #endif if( !closed ) EQWARN << "Could not close write socket: " << base::sysError << std::endl; } _readFD = INVALID_SOCKET; _writeFD = INVALID_SOCKET; _fireStateChanged(); }
void SocketConnection::_exitAIOAccept() { if( _overlappedAcceptData ) { free( _overlappedAcceptData ); _overlappedAcceptData = 0; } _exitAIORead(); }
void NamedPipeConnection::_exitAIOAccept() { _exitAIORead(); }