📄 ncbi_socket.hpp
字号:
/* @} *///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPLEMENTATION of INLINE functions//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CSocket:://inline EIO_Status CSocket::Shutdown(EIO_Event how){ return m_Socket ? SOCK_Shutdown(m_Socket, how) : eIO_Closed;}inline EIO_Status CSocket::Wait(EIO_Event event, const STimeout* timeout){ return m_Socket ? SOCK_Wait(m_Socket, event, timeout) : eIO_Closed; }inline EIO_Status CSocket::PushBack(const void* buf, size_t size){ return m_Socket ? SOCK_PushBack(m_Socket, buf, size) : eIO_Closed;}inline EIO_Status CSocket::Abort(void){ return m_Socket ? SOCK_Abort(m_Socket) : eIO_Closed;}inline EIO_Status CSocket::GetStatus(EIO_Event direction) const{ return m_Socket ? SOCK_Status(m_Socket, direction) : eIO_Closed;}inline EOwnership CSocket::SetOwnership(EOwnership if_to_own){ EOwnership prev_ownership = m_IsOwned; m_IsOwned = if_to_own; return prev_ownership;}inline SOCK CSocket::GetSOCK(void) const{ return m_Socket;}inline EIO_Status CSocket::GetOSHandle(void* hnd_buf, size_t hnd_siz) const{ return m_Socket? SOCK_GetOSHandle(m_Socket, hnd_buf, hnd_siz) : eIO_Closed;} inline ESwitch CSocket::SetReadOnWrite(ESwitch read_on_write){ return m_Socket? SOCK_SetReadOnWrite(m_Socket, read_on_write) : eDefault;}inline ESwitch CSocket::SetDataLogging(ESwitch log){ return m_Socket? SOCK_SetDataLogging(m_Socket, log) : eDefault;}inline ESwitch CSocket::SetInterruptOnSignal(ESwitch interrupt){ return m_Socket? SOCK_SetInterruptOnSignal(m_Socket, interrupt) : eDefault;}inline void CSocket::SetReuseAddress(ESwitch reuse){ if ( m_Socket ) SOCK_SetReuseAddress(m_Socket, reuse);}inline bool CSocket::IsClientSide(void) const{ return m_Socket && SOCK_IsClientSide(m_Socket) ? true : false;}inline bool CSocket::IsServerSide(void) const{ return m_Socket && SOCK_IsServerSide(m_Socket) ? true : false;}inline bool CSocket::IsDatagram(void) const{ return m_Socket && SOCK_IsDatagram(m_Socket) ? true : false;}/////////////////////////////////////////////////////////////////////////////// CDatagramSocket:://inline EIO_Status CDatagramSocket::Wait(const STimeout* timeout){ return m_Socket ? DSOCK_WaitMsg(m_Socket, timeout) : eIO_Closed;}inline EIO_Status CDatagramSocket::Clear(EIO_Event direction){ return m_Socket ? DSOCK_WipeMsg(m_Socket, direction) : eIO_Closed;}inline EIO_Status CDatagramSocket::SetBroadcast(bool do_broadcast){ return m_Socket ? DSOCK_SetBroadcast(m_Socket, do_broadcast) : eIO_Closed;}/////////////////////////////////////////////////////////////////////////////// CListeningSocket:://inline EIO_Status CListeningSocket::GetStatus(void) const{ return m_Socket ? eIO_Success : eIO_Closed;}inline EOwnership CListeningSocket::SetOwnership(EOwnership if_to_own){ EOwnership prev_ownership = m_IsOwned; m_IsOwned = if_to_own; return prev_ownership;}inline LSOCK CListeningSocket::GetLSOCK(void) const{ return m_Socket;}inline EIO_Status CListeningSocket::GetOSHandle(void* handle_buf, size_t handle_size) const{ return m_Socket ? LSOCK_GetOSHandle(m_Socket, handle_buf, handle_size) : eIO_Closed;}/////////////////////////////////////////////////////////////////////////////// CSocketAPI:://inline void CSocketAPI::AllowSigPipe(void){ SOCK_AllowSigPipeAPI();}inline const STimeout* CSocketAPI::SetSelectInternalRestartTimeout(const STimeout* tmo){ return SOCK_SetSelectInternalRestartTimeout(tmo);}inline EIO_Status CSocketAPI::Initialize(void){ return SOCK_InitializeAPI();}inline EIO_Status CSocketAPI::Shutdown(void){ return SOCK_ShutdownAPI();}inline ESwitch CSocketAPI::SetReadOnWrite(ESwitch read_on_write){ return SOCK_SetReadOnWriteAPI(read_on_write);}inline ESwitch CSocketAPI::SetDataLogging(ESwitch log){ return SOCK_SetDataLoggingAPI(log);}inline ESwitch CSocketAPI::SetInterruptOnSignal(ESwitch interrupt){ return SOCK_SetInterruptOnSignalAPI(interrupt);}inline ESwitch CSocketAPI::SetReuseAddress(ESwitch reuse){ return SOCK_SetReuseAddressAPI(reuse);}inline unsigned int CSocketAPI::HostToNetLong(unsigned int value){ return SOCK_HostToNetLong(value);}inline unsigned int CSocketAPI::NetToHostLong(unsigned int value){ return SOCK_NetToHostLong(value);}inline unsigned short CSocketAPI::HostToNetShort(unsigned short value){ return SOCK_HostToNetShort(value);}inline unsigned short CSocketAPI::NetToHostShort(unsigned short value){ return SOCK_NetToHostShort(value);}/////////////////////////////////////////////////////////////////////////////END_NCBI_SCOPE/* * --------------------------------------------------------------------------- * $Log: ncbi_socket.hpp,v $ * Revision 1000.3 2003/12/02 20:27:51 gouriano * PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R6.36 * * Revision 6.36 2003/11/25 15:07:40 lavr * CSocket::GetStatus() to pass eIO_Open to SOCK_Status() * * Revision 6.35 2003/11/24 19:22:24 lavr * SetSelectInternalRestartTimeout() to accept ptr to STimeout * * Revision 6.34 2003/11/18 20:18:49 lavr * +SetSelectInternalRestartTimeout() * * Revision 6.33 2003/11/12 17:43:53 lavr * Few (non-functional) rearrangements * * Revision 6.32 2003/10/24 16:51:11 lavr * GetTimeout(eIO_ReadWrite): return the lesser of eIO_Read and eIO_Write * * Revision 6.31 2003/10/23 12:14:52 lavr * Socket feature setters made returning old feature values * * Revision 6.30 2003/10/09 19:58:26 vakatov * Fine-tune the set of included CORELIB headers, mostly to avoid the weird * dependence of XNCBI library on ICC 7.1. * * Revision 6.29 2003/08/25 14:37:07 lavr * Introduce CPollable and more generic SCocketAPI::Poll() * * Revision 6.28 2003/07/15 16:49:16 lavr * +CSocket::GetPeerAddress(void) * * Revision 6.27 2003/05/31 05:12:09 lavr * Fix return value type of HostToNetShort and NetToHostShort * * Revision 6.26 2003/05/21 17:51:50 lavr * SOCK_Abort() redeclared protected in CDatagramSocket * * Revision 6.25 2003/05/20 21:24:55 lavr * +CSocket::Abort() * * Revision 6.24 2003/05/14 03:46:44 lavr * Match revised datagram socket API * * Revision 6.23 2003/04/30 17:03:22 lavr * Modified prototypes for CDatagramSocket::Send() and CDatagramSocket::Recv() * * Revision 6.22 2003/04/11 20:58:12 lavr * CDatagramSocket:: API defined completely * * Revision 6.21 2003/04/09 19:05:55 siyan * Added doxygen support * * Revision 6.20 2003/02/20 17:55:09 lavr * Inlining CSocket::Shutdown() and CSocket::Wait() * * Revision 6.19 2003/02/14 22:03:32 lavr * Add internal CSocket timeouts and document them * * Revision 6.18 2003/01/28 19:29:07 lavr * DSOCK: Remove reference to kEmptyStr and thus to xncbi * * Revision 6.17 2003/01/26 04:28:37 lavr * Quick fix CDatagramSocket ctor ambiguity * * Revision 6.16 2003/01/24 23:01:32 lavr * Added class CDatagramSocket * * Revision 6.15 2003/01/07 22:01:43 lavr * ChangeLog message corrected * * Revision 6.14 2003/01/07 21:58:24 lavr * Comment corrected * * Revision 6.13 2002/12/19 14:51:48 dicuccio * Added export specifier for Win32 DLL builds. * * Revision 6.12 2002/12/04 16:54:08 lavr * Add extra parameter "log" to CSocket() constructor and CSocket::Connect() * * Revision 6.11 2002/11/14 01:11:33 lavr * Minor formatting changes * * Revision 6.10 2002/09/19 18:05:25 lavr * Header file guard macro changed * * Revision 6.9 2002/09/17 20:45:28 lavr * A typo corrected * * Revision 6.8 2002/09/16 22:32:47 vakatov * Allow to change ownership for the underlying sockets "on-the-fly"; * plus some minor (mostly formal) code and comments rearrangements * * Revision 6.7 2002/08/27 03:19:29 lavr * CSocketAPI:: Removed methods: htonl(), htons(), ntohl(), ntohs(). Added * as replacements: {Host|Net}To{Net|Host}{Long|Short}() (see ncbi_socket.h) * * Revision 6.6 2002/08/15 18:45:03 lavr * CSocketAPI::Poll() documented in more details in ncbi_socket.h(SOCK_Poll) * * Revision 6.5 2002/08/14 15:04:37 sadykov * Prepend "inline" for GetOSHandle() method impl * * Revision 6.4 2002/08/13 19:28:29 lavr * Move most methods out-of-line; fix inline methods to have "inline" * * Revision 6.3 2002/08/12 20:58:09 lavr * More comments on parameters usage of certain methods * * Revision 6.2 2002/08/12 20:24:04 lavr * Resolve expansion mess with byte order marcos (use calls instead) -- FreeBSD * * Revision 6.1 2002/08/12 15:11:34 lavr * Initial revision * * =========================================================================== */#endif /* CONNECT___NCBI_SOCKET__HPP */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -