NCBI C++ ToolKit
|
Classes | |
struct | SSOCK_ApproveInfo |
User-level connection approval hook. More... | |
struct | SSOCK_Poll |
I/O polling structure. More... | |
struct | SSOCK_ErrInfo |
struct | SPOLLABLE_Poll |
class | CPollable |
class | CTrigger |
CTrigger:: More... | |
class | CSocket |
CSocket:: More... | |
class | CDatagramSocket |
CDatagramSocket:: More... | |
class | CListeningSocket |
CListeningSocket:: More... | |
class | CSocketAPI |
CSocketAPI:: More... | |
struct | CSocketAPI::SPoll |
Polling structure m_Event can be either of eIO_Open, eIO_Read, eIO_Write, eIO_ReadWrite. More... | |
class | CUNIXSocket |
class | CUNIXListeningSocket |
Macros | |
#define | SOCK_Destroy(s) SOCK_Close(s) |
#define | SOCK_NetToHostLong SOCK_HostToNetLong |
#define | SOCK_NetToHostShort SOCK_HostToNetShort |
#define | NCBI_SOCK_DEPRECATED NCBI_DEPRECATED |
#define | SOCK_ntohl SOCK_htonl |
#define | SOCK_ntohs SOCK_htons |
#define | REG_CONN_TLS_LOGLEVEL "TLS_LOGLEVEL" |
#define | DEF_CONN_TLS_LOGLEVEL "" |
Typedefs | |
typedef unsigned | EBIO_Event |
typedef unsigned | EBIO_Status |
typedef struct LSOCK_tag * | LSOCK |
typedef struct SOCK_tag * | SOCK |
typedef struct TRIGGER_tag * | TRIGGER |
typedef EIO_Status(* | FSOCK_ApproveHook) (const SSOCK_ApproveInfo *info, void *data) |
The approve hook is global per API and gets called with an arbitrary user "data", if so desired as a second argument, which was specified when the hook was installed with the SOCK_SetApproveHookAPI() call. More... | |
typedef unsigned int | TSOCK_Flags |
bitwise "OR" of ESOCK_Flags More... | |
typedef void(* | FSOCK_ErrHook) (const SSOCK_ErrInfo *info, void *data) |
typedef struct SPOLLABLE_tag * | POLLABLE |
typedef struct SNcbiCred * | NCBI_CRED |
Opaque type for credentials. More... | |
typedef const struct SOCKSSL_struct * | SOCKSSL |
Opaque type for SSL implementation. More... | |
typedef SOCKSSL(* | FSSLSetup) (void) |
SSL setup callback. More... | |
Functions | |
SOCKSSL | NcbiSetupGnuTls (void) |
Explicitly setup GNUTLS library to support SSL in ncbi_socket.h[pp]. More... | |
NCBI_CRED | NcbiCredGnuTls (void *xcred) |
Convert a native GNUTLS certificate credentials' handle into an abstract toolkit handle. More... | |
SOCKSSL | NcbiSetupMbedTls (void) |
Explicitly setup mbedTLS library to support SSL in ncbi_socket.h[pp]. More... | |
NCBI_CRED | NcbiCredMbedTls (void *xcert, void *xpkey) |
Convert native mbedTLS certificate credentials' handles into an abstract toolkit handle. More... | |
EIO_Status | SOCK_InitializeAPI (void) |
Initialize all internal/system data & resources to be used by the SOCK API. More... | |
EIO_Status | SOCK_ShutdownAPI (void) |
Cleanup; destroy all internal/system data & resources used by the SOCK API. More... | |
size_t | SOCK_OSHandleSize (void) |
Get size of OS-dependent native socket handle. More... | |
void | SOCK_AllowSigPipeAPI (void) |
By default (on UNIX platforms) the SOCK API functions automagically call "signal(SIGPIPE, SIG_IGN)" on initialization. More... | |
void | SOCK_SetApproveHookAPI (FSOCK_ApproveHook hook, void *data) |
The hook is installed when non-NULL, and de-installed otherwise. More... | |
const STimeout * | SOCK_SetSelectInternalRestartTimeout (const STimeout *timeslice) |
This is a helper call that can improve I/O behavior. More... | |
ESOCK_IOWaitSysAPI | SOCK_SetIOWaitSysAPI (ESOCK_IOWaitSysAPI api) |
This is a helper call that can improve I/O performance (ignored for MSVC). More... | |
EIO_Status | TRIGGER_Create (TRIGGER *trigger, ESwitch log) |
Create an event trigger. More... | |
EIO_Status | TRIGGER_Close (TRIGGER trigger) |
Close an event trigger. More... | |
EIO_Status | TRIGGER_Set (TRIGGER trigger) |
Set an event trigger. More... | |
EIO_Status | TRIGGER_IsSet (TRIGGER trigger) |
Check whether the trigger has been set. More... | |
EIO_Status | TRIGGER_Reset (TRIGGER trigger) |
Reset the trigger. More... | |
EIO_Status | LSOCK_CreateEx (unsigned short port, unsigned short backlog, LSOCK *lsock, TSOCK_Flags flags) |
[SERVER-side] Create and initialize the server-side(listening) socket (socket() + bind() + listen()) More... | |
EIO_Status | LSOCK_Create (unsigned short port, unsigned short backlog, LSOCK *lsock) |
[SERVER-side] Create and initialize the server-side(listening) socket Same as LSOCK_CreateEx() called with the last argument provided as fSOCK_LogDefault. More... | |
EIO_Status | LSOCK_AcceptEx (LSOCK lsock, const STimeout *timeout, SOCK *sock, TSOCK_Flags flags) |
[SERVER-side] Accept connection from a client. More... | |
EIO_Status | LSOCK_Accept (LSOCK lsock, const STimeout *timeout, SOCK *sock) |
[SERVER-side] Accept connection from a client. More... | |
EIO_Status | LSOCK_Close (LSOCK lsock) |
[SERVER-side] Close the listening socket, destroy relevant internal data. More... | |
EIO_Status | LSOCK_GetOSHandleEx (LSOCK lsock, void *handle_buf, size_t handle_size, EOwnership owndership) |
Get an OS-dependent native socket handle to use by platform-specific API. More... | |
EIO_Status | LSOCK_GetOSHandle (LSOCK lsock, void *handle_buf, size_t handle_size) |
Same as LSOCK_GetOSHandleEx(lsock, handle_buf, handle_size, eNoOwnership). More... | |
unsigned short | LSOCK_GetPort (LSOCK lsock, ENH_ByteOrder byte_order) |
Get socket port number, which it listens on. More... | |
EIO_Status | SOCK_CreateEx (const char *host, unsigned short port, const STimeout *timeout, SOCK *sock, const void *data, size_t size, TSOCK_Flags flags) |
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()]) More... | |
EIO_Status | SOCK_Create (const char *host, unsigned short port, const STimeout *timeout, SOCK *sock) |
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()]) Equivalent to SOCK_CreateEx(host, port, timeout, sock, 0, 0, fSOCK_LogDefault). More... | |
EIO_Status | SOCK_CreateOnTopEx (const void *handle, size_t handle_size, SOCK *sock, const void *data, size_t size, TSOCK_Flags flags) |
[SERVER-side] Create a SOCKet on top of either an OS-dependent "handle" (file descriptor on Unix, SOCKET on MS-Windows) or an existing SOCK object. More... | |
EIO_Status | SOCK_CreateOnTop (const void *handle, size_t handle_size, SOCK *sock) |
[SERVER-side] Create a socket on top of a "handle". More... | |
EIO_Status | SOCK_Reconnect (SOCK sock, const char *host, unsigned short port, const STimeout *timeout) |
[CLIENT-side] Close the socket referred to by "sock" and then connect it to another "host:port"; fail if it takes more than "timeout" (close() + connect() [+ select()]) More... | |
EIO_Status | SOCK_Shutdown (SOCK sock, EIO_Event how) |
Shutdown the connection in only one direction (specified by "direction"). More... | |
EIO_Status | SOCK_Close (SOCK sock) |
Close the SOCK handle, and destroy all relevant internal data. More... | |
EIO_Status | SOCK_CloseEx (SOCK sock, int destroy) |
Close the SOCK handle, and conditionally destroy relevant internal data. More... | |
EIO_Status | SOCK_CloseOSHandle (const void *handle, size_t handle_size) |
Close socket OS handle (ungracefully aborting the connection if necessary). More... | |
EIO_Status | SOCK_Wait (SOCK sock, EIO_Event event, const STimeout *timeout) |
Block on the socket until either the specified "event" is available or "timeout" expires (if "timeout" is NULL then assume it infinite). More... | |
EIO_Status | SOCK_Poll (size_t n, SSOCK_Poll polls[], const STimeout *timeout, size_t *n_ready) |
Block until at least one of the sockets enlisted in "polls" array (of size "n") becomes available for requested operation (SSOCK_Poll::event), or until timeout expires (wait indefinitely if timeout is passed as NULL). More... | |
EIO_Status | SOCK_SetTimeout (SOCK sock, EIO_Event event, const STimeout *timeout) |
Specify timeout for the connection I/O (see SOCK_[Read|Write|Close]()). More... | |
const STimeout * | SOCK_GetTimeout (SOCK sock, EIO_Event event) |
Get the connection's i/o timeout (or NULL, if the timeout is infinite). More... | |
EIO_Status | SOCK_Read (SOCK sock, void *buf, size_t size, size_t *n_read, EIO_ReadMethod how) |
Read/peek up to "size" bytes from "sock" to a buffer pointed to by "buf". More... | |
EIO_Status | SOCK_ReadLine (SOCK sock, char *line, size_t size, size_t *n_read) |
Read a line from SOCK. More... | |
EIO_Status | SOCK_Pushback (SOCK sock, const void *data, size_t size) |
Push the specified data back to the socket's input queue (in the socket's internal read buffer). More... | |
EIO_Status | SOCK_Status (SOCK sock, EIO_Event direction) |
Return low-level socket I/O status of *last* socket operation. More... | |
EIO_Status | SOCK_Write (SOCK sock, const void *data, size_t size, size_t *n_written, EIO_WriteMethod how) |
Write "size" bytes of "data" to "sock". More... | |
EIO_Status | SOCK_Abort (SOCK sock) |
If there is outstanding connection or output data pending, cancel it. More... | |
unsigned short | SOCK_GetLocalPortEx (SOCK sock, int trueport, ENH_ByteOrder byte_order) |
Get local port of the socket (true or cached / stored). More... | |
unsigned short | SOCK_GetLocalPort (SOCK sock, ENH_ByteOrder byte_order) |
Get local port of the socket. More... | |
void | SOCK_GetPeerAddress (SOCK sock, unsigned int *host, unsigned short *port, ENH_ByteOrder byte_order) |
Get host and port of the socket's peer (remote end). More... | |
unsigned short | SOCK_GetRemotePort (SOCK sock, ENH_ByteOrder byte_order) |
Get remote port of the socket (the port it is connected to). More... | |
char * | SOCK_GetPeerAddressStringEx (SOCK sock, char *buf, size_t bufsize, ESOCK_AddressFormat format) |
char * | SOCK_GetPeerAddressString (SOCK sock, char *buf, size_t bufsize) |
Equivalent to SOCK_GetPeerAddressStringEx(.,.,.,eSAF_Full) More... | |
EIO_Status | SOCK_GetOSHandleEx (SOCK sock, void *handle_buf, size_t handle_size, EOwnership ownership) |
Get an OS-dependent native socket handle to use by platform-specific API. More... | |
EIO_Status | SOCK_GetOSHandle (SOCK sock, void *handle_buf, size_t handle_size) |
Same as SOCK_GetOSHandleEx(sock, handle_buf, handle_size, eNoOwnership). More... | |
ESwitch | SOCK_SetReadOnWriteAPI (ESwitch on_off) |
By default, sockets will not try to read data from inside SOCK_Write(). More... | |
ESwitch | SOCK_SetReadOnWrite (SOCK sock, ESwitch on_off) |
Control the reading-while-writing feature for socket "sock" individually. More... | |
void | SOCK_SetCork (SOCK sock, int on_off) |
Control OS-defined send strategy by disabling/enabling the TCP layer to send incomplete network frames (packets). More... | |
void | SOCK_DisableOSSendDelay (SOCK sock, int on_off) |
Control OS-defined send strategy by disabling/enabling the TCP Nagle algorithm (which is on by default) that packs multiple requests into a single packet and thus transfers the data in fewer transactions, miminizing the network traffic and generally bursting the throughput. More... | |
EIO_Status | DSOCK_CreateEx (SOCK *sock, TSOCK_Flags flags) |
Create a datagram socket. More... | |
EIO_Status | DSOCK_Create (SOCK *sock) |
Same as DSOCK_CreateEx(, fSOCK_LogDefault) More... | |
EIO_Status | DSOCK_Bind (SOCK sock, unsigned short port) |
Assosiate a datagram socket with a local port. More... | |
EIO_Status | DSOCK_Connect (SOCK sock, const char *host, unsigned short port) |
Associate a datagram socket with a destination address. More... | |
EIO_Status | DSOCK_WaitMsg (SOCK sock, const STimeout *timeout) |
Wait for a datagram in a datagram socket. More... | |
EIO_Status | DSOCK_SendMsg (SOCK sock, const char *host, unsigned short port, const void *data, size_t datalen) |
Send a datagram to a datagram socket. More... | |
EIO_Status | DSOCK_RecvMsg (SOCK sock, void *buf, size_t bufsize, size_t maxmsglen, size_t *msglen, unsigned int *sender_addr, unsigned short *sender_port) |
Receive a datagram from a datagram socket. More... | |
EIO_Status | DSOCK_WipeMsg (SOCK sock, EIO_Event direction) |
Clear message froma datagram socket. More... | |
EIO_Status | DSOCK_SetBroadcast (SOCK sock, int broadcast) |
Set a datagram socket for broadcast. More... | |
TNCBI_BigCount | DSOCK_GetMessageCount (SOCK sock, EIO_Event direction) |
Get message count. More... | |
int | SOCK_IsDatagram (SOCK sock) |
Check whether a socket is a datagram one. More... | |
int | SOCK_IsClientSide (SOCK sock) |
Check whether a socket is client-side. More... | |
int | SOCK_IsServerSide (SOCK sock) |
Check whether a socket is server-side. More... | |
int | SOCK_IsUNIX (SOCK sock) |
Check whether a socket is UNIX type. More... | |
int | SOCK_IsSecure (SOCK sock) |
Check whether a socket is using SSL (Secure Socket Layer). More... | |
TNCBI_BigCount | SOCK_GetPosition (SOCK sock, EIO_Event direction) |
Get current read or write position within a socket. More... | |
TNCBI_BigCount | SOCK_GetCount (SOCK sock, EIO_Event direction) |
Get counts of read or written bytes. More... | |
TNCBI_BigCount | SOCK_GetTotalCount (SOCK sock, EIO_Event direction) |
Get the total volume of data transferred by a socket. More... | |
ESwitch | SOCK_SetInterruptOnSignalAPI (ESwitch on_off) |
Control restartability of I/O interrupted by signals. More... | |
ESwitch | SOCK_SetInterruptOnSignal (SOCK sock, ESwitch on_off) |
Control restartability of I/O interrupted by signals on a per-socket basis. More... | |
ESwitch | SOCK_SetReuseAddressAPI (ESwitch on_off) |
Control address reuse for socket addresses taken by the API. More... | |
void | SOCK_SetReuseAddress (SOCK sock, int on_off) |
Control reuse of socket addresses on per-socket basis Note: only a boolean parameter value is can be used here. More... | |
ESwitch | SOCK_SetDataLoggingAPI (ESwitch log) |
By default data are not logged. More... | |
ESwitch | SOCK_SetDataLogging (SOCK sock, ESwitch log) |
Control the data logging for socket "sock" individually. More... | |
void | SOCK_SetErrHookAPI (FSOCK_ErrHook hook, void *data) |
EIO_Status | POLLABLE_Poll (size_t n, SPOLLABLE_Poll polls[], const STimeout *timeout, size_t *n_ready) |
Poll for I/O readiness. More... | |
ESOCK_Type | POLLABLE_What (POLLABLE) |
Identifies a non-NULL POLLABLE. More... | |
POLLABLE | POLLABLE_FromSOCK (SOCK) |
Conversion utilities from handles to POLLABLEs, and back. More... | |
POLLABLE | POLLABLE_FromLSOCK (LSOCK) |
POLLABLE | POLLABLE_FromTRIGGER (TRIGGER) |
SOCK | POLLABLE_ToSOCK (POLLABLE) |
LSOCK | POLLABLE_ToLSOCK (POLLABLE) |
TRIGGER | POLLABLE_ToTRIGGER (POLLABLE) |
int | SOCK_ntoa (unsigned int addr, char *buf, size_t bufsize) |
Convert IP address to a string in dotted notation. More... | |
int | SOCK_isipEx (const char *host, int fullquad) |
Check whether the given string represents a valid IPv4 address. More... | |
int | SOCK_isip (const char *host) |
Equivalent of SOCK_isip(host, 0) More... | |
int | SOCK_IsLoopbackAddress (unsigned int ip) |
Check whether an address is a loopback one. More... | |
unsigned int | SOCK_HostToNetLong (unsigned int value) |
See man for the BSDisms, htonl() and htons(). More... | |
unsigned short | SOCK_HostToNetShort (unsigned short value) |
See man for the BSDisms, htonl() and htons(). More... | |
unsigned int | SOCK_htonl (unsigned int) |
unsigned short | SOCK_htons (unsigned short) |
int | SOCK_gethostnameEx (char *name, size_t namelen, ESwitch log) |
Get the local host name. More... | |
int | SOCK_gethostname (char *name, size_t namelen) |
Same as SOCK_gethostnameEx(,,<current API data logging>) More... | |
unsigned int | SOCK_gethostbynameEx (const char *hostname, ESwitch log) |
Find and return IPv4 address of a named host. More... | |
unsigned int | SOCK_gethostbyname (const char *hostname) |
Same as SOCK_gethostbynameEx(,<current API data logging>) More... | |
const char * | SOCK_gethostbyaddrEx (unsigned int addr, char *name, size_t namelen, ESwitch log) |
Take IPv4 host address (in network byte order) or 0 for current host, and fill out the provided buffer with the name, which the address corresponds to (in case of multiple names the primary name is used). More... | |
const char * | SOCK_gethostbyaddr (unsigned int addr, char *name, size_t namelen) |
Same as SOCK_gethostbyaddrEx(,,<current API data logging>) More... | |
unsigned int | SOCK_GetLoopbackAddress (void) |
Get loopback IPv4 address. More... | |
unsigned int | SOCK_GetLocalHostAddress (ESwitch reget) |
Get (and cache for faster follow-up retrievals) IPv4 address of local host. More... | |
const char * | SOCK_StringToHostPort (const char *str, unsigned int *host, unsigned short *port) |
Read (skipping leading blanks) "[host][:port]" from a string stopping at either EOL or a blank character. More... | |
size_t | SOCK_HostPortToString (unsigned int host, unsigned short port, char *buf, size_t bufsize) |
Print numeric string "host:port" into a buffer provided, not to exceed 'bufsize' bytes (including the teminating '\0' character). More... | |
void | SOCK_SetupSSL (FSSLSetup setup) |
Store SSL setup callback until actual initialization. More... | |
EIO_Status | SOCK_SetupSSLEx (FSSLSetup setup) |
Take SSL setup callback, and then init the entire API (SOCK + SSL). More... | |
const char * | SOCK_SSLName (void) |
Return an SSL provider name (in a const static storage), with special considerations: return NULL if SSL has not been set up (yet), and return "" if SSL has not been (properly) initialized for use. More... | |
virtual EIO_Status | CPollable::GetOSHandle (void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const =0 |
virtual POLLABLE | CPollable::GetPOLLABLE (void) const =0 |
virtual | CPollable::~CPollable () |
CPollable::CPollable (void) | |
CPollable::CPollable (const CPollable &) | |
CPollable & | CPollable::operator= (const CPollable &) |
CTrigger::CTrigger (ESwitch log=eDefault) | |
IMPLEMENTATION of INLINE functions. More... | |
virtual | CTrigger::~CTrigger () |
EIO_Status | CTrigger::GetStatus (void) const |
EIO_Status | CTrigger::Set (void) |
EIO_Status | CTrigger::IsSet (void) |
EIO_Status | CTrigger::Reset (void) |
virtual EIO_Status | CTrigger::GetOSHandle (void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const |
Access to the system-specific handle. More... | |
TRIGGER | CTrigger::GetTRIGGER (void) const |
Access to the underlying "TRIGGER". More... | |
virtual POLLABLE | CTrigger::GetPOLLABLE (void) const |
CSocket::CSocket (void) | |
CSocket:: More... | |
CSocket::CSocket (const string &host, unsigned short port, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) | |
Create a client-side socket connected to "host:port". More... | |
CSocket::CSocket (const string &hostport, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) | |
Create a client-side socket connected to "host:port". More... | |
CSocket::CSocket (unsigned int host, unsigned short port, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) | |
Variant of the above, which takes host as a binary value in network byte order. More... | |
virtual | CSocket::~CSocket (void) |
Call Close(), then self-destruct. More... | |
EIO_Status | CSocket::GetStatus (EIO_Event direction) const |
Return status of *last* I/O operation without making any actual I/O. More... | |
EIO_Status | CSocket::Connect (const string &host, unsigned short port, const STimeout *timeout=kDefaultTimeout, TSOCK_Flags flags=fSOCK_LogDefault) |
Connect to "host:port". More... | |
EIO_Status | CSocket::Connect (const string &hostport, const STimeout *timeout=kDefaultTimeout, TSOCK_Flags flags=fSOCK_LogDefault) |
Connect to "host:port". More... | |
EIO_Status | CSocket::Reconnect (const STimeout *timeout=kDefaultTimeout) |
Reconnect to the same address. More... | |
EIO_Status | CSocket::Shutdown (EIO_Event how) |
Shutdown socket I/O in the specified direction. More... | |
EIO_Status | CSocket::Close (void) |
Close socket. More... | |
EIO_Status | CSocket::Wait (EIO_Event event, const STimeout *timeout) |
Wait for I/O availability in the socket. More... | |
EIO_Status | CSocket::SetTimeout (EIO_Event event, const STimeout *timeout) |
Set timeout for I/O in the specified direction. More... | |
const STimeout * | CSocket::GetTimeout (EIO_Event event) const |
Get timeout for I/O in the specified direction. More... | |
EIO_Status | CSocket::Read (void *buf, size_t size, size_t *n_read=0, EIO_ReadMethod how=eIO_ReadPlain) |
Read from socket. More... | |
EIO_Status | CSocket::ReadLine (string &str) |
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs). More... | |
EIO_Status | CSocket::ReadLine (char *buf, size_t size, size_t *n_read=0) |
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs). More... | |
EIO_Status | CSocket::Pushback (const void *buf, size_t size) |
Push back data to socket (to be read out first). More... | |
EIO_Status | CSocket::Write (const void *buf, size_t size, size_t *n_written=0, EIO_WriteMethod how=eIO_WritePersist) |
Write to socket. More... | |
EIO_Status | CSocket::Abort (void) |
Abort socket connection. More... | |
unsigned short | CSocket::GetLocalPort (ENH_ByteOrder byte_order, bool trueport=false) const |
Get socket local port number. More... | |
unsigned short | CSocket::GetRemotePort (ENH_ByteOrder byte_order) const |
Get socket remote port number. More... | |
void | CSocket::GetPeerAddress (unsigned int *host, unsigned short *port, ENH_ByteOrder byte_order) const |
Get peer address. More... | |
string | CSocket::GetPeerAddress (ESOCK_AddressFormat format=eSAF_Full) const |
Get peer address as a text string. More... | |
virtual EIO_Status | CSocket::GetOSHandle (void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const |
Access to the system-specific socket handle. More... | |
ESwitch | CSocket::SetReadOnWrite (ESwitch read_on_write=eOn) |
ESwitch | CSocket::SetInterruptOnSignal (ESwitch interrupt=eOn) |
void | CSocket::SetReuseAddress (ESwitch reuse=eOff) |
void | CSocket::SetCork (bool on_off=true) |
void | CSocket::DisableOSSendDelay (bool on_off=true) |
ESwitch | CSocket::SetDataLogging (ESwitch log=eOn) |
bool | CSocket::IsDatagram (void) const |
bool | CSocket::IsClientSide (void) const |
bool | CSocket::IsServerSide (void) const |
bool | CSocket::IsUNIX (void) const |
bool | CSocket::IsSecure (void) const |
TNCBI_BigCount | CSocket::GetPosition (EIO_Event direction) const |
Positions and stats (direction is either eIO_Read or eIO_Write). More... | |
TNCBI_BigCount | CSocket::GetCount (EIO_Event direction) const |
TNCBI_BigCount | CSocket::GetTotalCount (EIO_Event direction) const |
void | CSocket::Reset (SOCK sock, EOwnership if_to_own, ECopyTimeout whence) |
Close the current underlying "SOCK" (if any, and if owned), and from now on use "sock" as the underlying "SOCK" instead. More... | |
EOwnership | CSocket::SetOwnership (EOwnership if_to_own) |
Specify if this "CSocket" is to own the underlying "SOCK". More... | |
SOCK | CSocket::GetSOCK (void) const |
Access to the underlying "SOCK". More... | |
bool | CSocket::IsEmpty (void) const |
virtual POLLABLE | CSocket::GetPOLLABLE (void) const |
CDatagramSocket::CDatagramSocket (TSOCK_Flags flags=fSOCK_LogDefault) | |
CDatagramSocket:: More... | |
EIO_Status | CDatagramSocket::Bind (unsigned short port) |
EIO_Status | CDatagramSocket::Connect (const string &host, unsigned short port) |
EIO_Status | CDatagramSocket::Connect (const string &hostport) |
EIO_Status | CDatagramSocket::Connect (unsigned int host, unsigned short port) |
EIO_Status | CDatagramSocket::Wait (const STimeout *timeout=kInfiniteTimeout) |
EIO_Status | CDatagramSocket::Recv (void *buf, size_t buflen, size_t *msglen=0, string *sender_host=0, unsigned short *sender_port=0, size_t maxmsglen=0) |
EIO_Status | CDatagramSocket::Send (const void *data, size_t datalen, const string &host=string(), unsigned short port=0) |
EIO_Status | CDatagramSocket::Clear (EIO_Event direction) |
EIO_Status | CDatagramSocket::SetBroadcast (bool do_broadcast=true) |
TNCBI_BigCount | CDatagramSocket::GetMessageCount (EIO_Event direction) const |
Message count. More... | |
EIO_Status | CDatagramSocket::Shutdown (EIO_Event how) |
EIO_Status | CDatagramSocket::Reconnect (const STimeout *timeout) |
EIO_Status | CDatagramSocket::Abort (void) |
CListeningSocket::CListeningSocket (void) | |
CListeningSocket:: More... | |
CListeningSocket::CListeningSocket (unsigned short port, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault) | |
virtual | CListeningSocket::~CListeningSocket (void) |
Call Close(), then self-destruct. More... | |
EIO_Status | CListeningSocket::GetStatus (void) const |
Return eIO_Closed if not yet bound or Close()'d. More... | |
EIO_Status | CListeningSocket::Listen (unsigned short port, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault) |
EIO_Status | CListeningSocket::Accept (CSocket *&sock, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) const |
EIO_Status | CListeningSocket::Accept (CSocket &sock, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) const |
EIO_Status | CListeningSocket::Close (void) |
virtual EIO_Status | CListeningSocket::GetOSHandle (void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const |
Access to the system-specific socket handle. More... | |
unsigned short | CListeningSocket::GetPort (ENH_ByteOrder byte_order) const |
Return port which the server listens on. More... | |
EOwnership | CListeningSocket::SetOwnership (EOwnership if_to_own) |
Specify if this "CListeningSocket" is to own the underlying "LSOCK". More... | |
LSOCK | CListeningSocket::GetLSOCK (void) const |
Access to the underlying "LSOCK". More... | |
bool | CListeningSocket::IsEmpty (void) const |
virtual POLLABLE | CListeningSocket::GetPOLLABLE (void) const |
static EIO_Status | CSocketAPI::Initialize (void) |
Generic. More... | |
static EIO_Status | CSocketAPI::Shutdown (void) |
static void | CSocketAPI::AllowSigPipe (void) |
static size_t | CSocketAPI::OSHandleSize (void) |
static EIO_Status | CSocketAPI::CloseOSHandle (const void *handle, size_t handle_size) |
static const STimeout * | CSocketAPI::SetSelectInternalRestartTimeout (const STimeout *timeout) |
Utility. More... | |
static ESOCK_IOWaitSysAPI | CSocketAPI::SetIOWaitSysAPI (ESOCK_IOWaitSysAPI api) |
static ESwitch | CSocketAPI::SetReadOnWrite (ESwitch read_on_write) |
Defaults (see also per-socket CSocket::SetReadOnWrite, etc.) More... | |
static ESwitch | CSocketAPI::SetInterruptOnSignal (ESwitch interrupt) |
static ESwitch | CSocketAPI::SetReuseAddress (ESwitch reuse) |
static ESwitch | CSocketAPI::SetDataLogging (ESwitch log) |
CSocketAPI::SPoll::SPoll (CPollable *pollable=0, EIO_Event event=eIO_Open) | |
static EIO_Status | CSocketAPI::Poll (vector< SPoll > &polls, const STimeout *timeout, size_t *n_ready=0) |
Poll a vector of CPollable objects for I/O readiness. More... | |
static string | CSocketAPI::ntoa (unsigned int host) |
BSD-like API. NB: when int, "host" must be in network byte order. More... | |
static bool | CSocketAPI::isip (const string &host, bool fullquad=false) |
static unsigned int | CSocketAPI::HostToNetLong (unsigned int value) |
static unsigned int | CSocketAPI::NetToHostLong (unsigned int value) |
static unsigned short | CSocketAPI::HostToNetShort (unsigned short value) |
static unsigned short | CSocketAPI::NetToHostShort (unsigned short value) |
static string | CSocketAPI::gethostname (ESwitch log=eOff) |
Return empty string on error. More... | |
static string | CSocketAPI::gethostbyaddr (unsigned int host, ESwitch log=eOff) |
Return empty string on error. More... | |
static unsigned int | CSocketAPI::gethostbyname (const string &host, ESwitch log=eOff) |
Return 0 on error. More... | |
static unsigned int | CSocketAPI::GetLoopbackAddress (void) |
Loopback address gets returned in network byte order. More... | |
static unsigned int | CSocketAPI::GetLocalHostAddress (ESwitch reget=eDefault) |
Local host address in network byte order (cached for faster retrieval) More... | |
static string | CSocketAPI::HostPortToString (unsigned int host, unsigned short port) |
See SOCK_HostPortToString() More... | |
static SIZE_TYPE | CSocketAPI::StringToHostPort (const string &str, unsigned int *host, unsigned short *port) |
Return position past the end of the parsed portion, NPOS on error. More... | |
EIO_Status | LSOCK_CreateUNIX (const char *path, unsigned short backlog, LSOCK *lsock, TSOCK_Flags flags) |
EIO_Status | SOCK_CreateUNIX (const char *path, const STimeout *timeout, SOCK *sock, const void *data, size_t size, TSOCK_Flags flags) |
CUNIXSocket::CUNIXSocket (void) | |
CUNIXSocket::CUNIXSocket (const string &filename, const STimeout *timeout=kInfiniteTimeout, TSOCK_Flags flags=fSOCK_LogDefault) | |
EIO_Status | CUNIXSocket::Connect (const string &filename, const STimeout *timeout=kDefaultTimeout, TSOCK_Flags flags=fSOCK_LogDefault) |
CUNIXListeningSocket::CUNIXListeningSocket (void) | |
CUNIXListeningSocket::CUNIXListeningSocket (const string &filename, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault) | |
IMPLEMENTATION of INLINE functions. More... | |
EIO_Status | CUNIXListeningSocket::Listen (const string &filename, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault) |
SOCKSSL | NcbiSetupTls (void) |
Setup a TLS (Transport Layer Security) provider library to support SSL in ncbi_socket.h[pp]. More... | |
NCBI_CRED | NcbiCreateTlsCertCredentials (const void *cert, size_t certsz, const void *pkey, size_t pkeysz) |
Build NCBI_CRED from memory buffers containing X.509 certificate and private key, respectively, in either PEM or DER format (independently of each other). More... | |
void | NcbiDeleteTlsCertCredentials (NCBI_CRED cred) |
Delete a NCBI_CRED handle created by NcbiCreateTlsCertCredentials(). More... | |
#define DEF_CONN_TLS_LOGLEVEL "" |
Definition at line 89 of file ncbi_tls.h.
#define NCBI_SOCK_DEPRECATED NCBI_DEPRECATED |
Definition at line 2113 of file ncbi_socket.h.
#define REG_CONN_TLS_LOGLEVEL "TLS_LOGLEVEL" |
Definition at line 88 of file ncbi_tls.h.
#define SOCK_Destroy | ( | s | ) | SOCK_Close(s) |
Definition at line 875 of file ncbi_socket.h.
#define SOCK_NetToHostLong SOCK_HostToNetLong |
Definition at line 2096 of file ncbi_socket.h.
#define SOCK_NetToHostShort SOCK_HostToNetShort |
Definition at line 2106 of file ncbi_socket.h.
#define SOCK_ntohl SOCK_htonl |
Definition at line 2117 of file ncbi_socket.h.
#define SOCK_ntohs SOCK_htons |
Definition at line 2120 of file ncbi_socket.h.
typedef unsigned EBIO_Event |
Definition at line 186 of file ncbi_socket.h.
typedef unsigned EBIO_Status |
Definition at line 187 of file ncbi_socket.h.
typedef EIO_Status(* FSOCK_ApproveHook) (const SSOCK_ApproveInfo *info, void *data) |
The approve hook is global per API and gets called with an arbitrary user "data", if so desired as a second argument, which was specified when the hook was installed with the SOCK_SetApproveHookAPI() call.
Definition at line 356 of file ncbi_socket.h.
typedef void(* FSOCK_ErrHook) (const SSOCK_ErrInfo *info, void *data) |
Definition at line 1960 of file ncbi_socket.h.
typedef SOCKSSL(* FSSLSetup) (void) |
SSL setup callback.
Definition at line 2312 of file ncbi_socket.h.
Definition at line 220 of file ncbi_socket.h.
Opaque type for credentials.
Definition at line 2303 of file ncbi_socket.h.
typedef struct SPOLLABLE_tag* POLLABLE |
Definition at line 1976 of file ncbi_socket.h.
Definition at line 223 of file ncbi_socket.h.
typedef const struct SOCKSSL_struct* SOCKSSL |
Opaque type for SSL implementation.
Definition at line 2308 of file ncbi_socket.h.
typedef struct TRIGGER_tag* TRIGGER |
Definition at line 226 of file ncbi_socket.h.
typedef unsigned int TSOCK_Flags |
bitwise "OR" of ESOCK_Flags
Definition at line 503 of file ncbi_socket.h.
enum ECopyTimeout |
Enumerator | |
---|---|
eCopyTimeoutsFromSOCK | |
eCopyTimeoutsToSOCK |
Definition at line 51 of file ncbi_socket.hpp.
enum ENH_ByteOrder |
Network and host byte order enumeration type.
Enumerator | |
---|---|
eNH_HostByteOrder | |
eNH_NetworkByteOrder |
Definition at line 192 of file ncbi_socket.h.
enum ESOCK_AddressFormat |
Get textual representation of the socket's peer.
For INET domain sockets, the result is of the form "aaa.bbb.ccc.ddd:ppppp"; for UNIX domain socket, the result is the name of the socket's file.
sock | [in] socket handle |
buf | [out] pointer to provided buffer to store the text to |
bufsize | [in] usable size of the buffer above |
format | [in] what parts of address to include |
Enumerator | |
---|---|
eSAF_Full | address in full, native form |
eSAF_Port | only numeric port if INET socket, empty otherwise |
eSAF_IP | only numeric IP if INET socket, empty otherwise |
Definition at line 1389 of file ncbi_socket.h.
enum ESOCK_ErrType |
User-level error hook.
Enumerator | |
---|---|
eSOCK_ErrInit | Socket layer initialization error. |
eSOCK_ErrDns | DNS-related error (unresolvable hostname) |
eSOCK_ErrIO | I/O-related error. |
Definition at line 1944 of file ncbi_socket.h.
enum ESOCK_Flags |
Enumerator | |
---|---|
fSOCK_LogOff | NB: logging is inherited in accepted SOCK. |
fSOCK_LogOn | |
fSOCK_LogDefault | |
fSOCK_KeepAlive | keep socket alive (if supported by OS) |
fSOCK_BindAny | bind to 0.0.0.0 (i.e. any), default |
fSOCK_BindLocal | bind to 127.0.0.1 only |
fSOCK_KeepOnExec | can be applied to all sockets |
fSOCK_CloseOnExec | can be applied to all sockets, default |
fSOCK_Secure | subsumes CloseOnExec regardless of Keep |
fSOCK_KeepOnClose | retain OS handle in SOCK_Close[Ex]() |
fSOCK_CloseOnClose | close OS handle in SOCK_Close[Ex]() |
fSOCK_ReadOnWrite | |
fSOCK_InterruptOnSignal |
Definition at line 488 of file ncbi_socket.h.
enum ESOCK_IOWaitSysAPI |
Selector of I/O wait system API: auto, poll(), or select().
Enumerator | |
---|---|
eSOCK_IOWaitSysAPIAuto | default; use some heuristics to choose API |
eSOCK_IOWaitSysAPIPoll | always use poll() |
eSOCK_IOWaitSysAPISelect | always use select() |
Definition at line 384 of file ncbi_socket.h.
enum ESOCK_Side |
enum ESOCK_Type |
Socket type (internal)
Enumerator | |
---|---|
eSOCK_Listening | |
eSOCK_Trigger | |
eSOCK_Socket | |
eSOCK_Datagram |
Definition at line 200 of file ncbi_socket.h.
|
inline |
Abort socket connection.
Definition at line 920 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_Abort().
Referenced by SNetServerConnectionImpl::Abort(), and CServer_ConnectionPool::CloseConnection().
|
protected |
EIO_Status CListeningSocket::Accept | ( | CSocket & | sock, |
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) | const |
sock | |
timeout |
Definition at line 555 of file ncbi_socket_cxx.cpp.
References assert, eCopyTimeoutsToSOCK, eIO_Success, eTakeOwnership, flags, LSOCK_AcceptEx(), CListeningSocket::m_Socket, and CSocket::Reset().
EIO_Status CListeningSocket::Accept | ( | CSocket *& | sock, |
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) | const |
sock | |
timeout |
Definition at line 526 of file ncbi_socket_cxx.cpp.
References assert, eCopyTimeoutsToSOCK, eIO_Success, eTakeOwnership, flags, LSOCK_AcceptEx(), CListeningSocket::m_Socket, CSocket::Reset(), SOCK_Abort(), and SOCK_Close().
Referenced by CAcceptRequest::CAcceptRequest().
|
inlinestatic |
Definition at line 1199 of file ncbi_socket.hpp.
References SOCK_AllowSigPipeAPI().
|
inline |
port | port is in host byte order |
Definition at line 1068 of file ncbi_socket.hpp.
References DSOCK_Bind(), and CSocket::m_Socket.
Referenced by SNetScheduleNotificationReceiver::SNetScheduleNotificationReceiver().
|
inline |
do_log |
Definition at line 1062 of file ncbi_socket.hpp.
References DSOCK_CreateEx(), flags, and CSocket::m_Socket.
|
inline |
direction |
Definition at line 1098 of file ncbi_socket.hpp.
References DSOCK_WipeMsg(), and CSocket::m_Socket.
|
inline |
port | |
backlog | |
flags |
Definition at line 1128 of file ncbi_socket.hpp.
References flags, LSOCK_CreateEx(), and CListeningSocket::m_Socket.
|
inline |
Definition at line 1121 of file ncbi_socket.hpp.
|
inline |
Close socket.
Definition at line 926 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_CloseEx().
Referenced by SNetServerConnectionImpl::Close(), SNetServerImpl::ConnectImpl(), CBDBEnvKeeperConnectionHandler::OnMessage(), and s_ReadMessage().
EIO_Status CListeningSocket::Close | ( | void | ) |
Definition at line 572 of file ncbi_socket_cxx.cpp.
References eIO_Success, eNoOwnership, LSOCK_Close(), CListeningSocket::m_IsOwned, and CListeningSocket::m_Socket.
Referenced by CServer_Listener::Passivate(), and CListeningSocket::~CListeningSocket().
|
inlinestatic |
Definition at line 1211 of file ncbi_socket.hpp.
References SOCK_CloseOSHandle().
EIO_Status CUNIXSocket::Connect | ( | const string & | filename, |
const STimeout * | timeout = kDefaultTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Definition at line 217 of file ncbi_socket_cxx.cpp.
References assert, CSocket::c_timeout, eIO_Close, eIO_Open, eIO_Read, eIO_Success, eIO_Unknown, eIO_Write, eNoOwnership, flags, kDefaultTimeout, CSocket::m_IsOwned, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, CSocket::r_timeout, SOCK_Close(), SOCK_CreateUNIX(), SOCK_SetTimeout(), SOCK_Status(), and CSocket::w_timeout.
|
inline |
host | host name or IP address as a string |
port | "port" is in host byte order |
Definition at line 1074 of file ncbi_socket.hpp.
References DSOCK_Connect(), and CSocket::m_Socket.
EIO_Status CSocket::Connect | ( | const string & | host, |
unsigned short | port, | ||
const STimeout * | timeout = kDefaultTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Connect to "host:port".
host | host name (or text IP address) of the host to connect to |
port | port number to connect at "host", always in host byte order |
timeout | maximal time to wait for connection to be established |
flags | additional socket properties (including logging) |
Definition at line 144 of file ncbi_socket_cxx.cpp.
References assert, CSocket::c_timeout, eIO_Close, eIO_Open, eIO_Read, eIO_Success, eIO_Unknown, eIO_Write, eNoOwnership, flags, kDefaultTimeout, CSocket::m_IsOwned, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, CSocket::r_timeout, SOCK_Close(), SOCK_CreateEx(), SOCK_SetTimeout(), SOCK_Status(), and CSocket::w_timeout.
Referenced by SNetServerImpl::ConnectImpl().
EIO_Status CDatagramSocket::Connect | ( | const string & | hostport | ) |
hostport | "host:port" as a string (no-port and no-host accepted, such as ":0") |
Definition at line 471 of file ncbi_socket_cxx.cpp.
References DSOCK_Connect(), eIO_Unknown, CSocket::m_Socket, SOCK_ntoa(), and SOCK_StringToHostPort().
EIO_Status CSocket::Connect | ( | const string & | hostport, |
const STimeout * | timeout = kDefaultTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Connect to "host:port".
hostport | "host:port" as a string |
timeout | maximal time to wait for connection to be established |
flags | additional socket properties (including logging) |
Definition at line 175 of file ncbi_socket_cxx.cpp.
References assert, CSocket::c_timeout, eIO_Close, eIO_Open, eIO_Read, eIO_Success, eIO_Unknown, eIO_Write, eNoOwnership, flags, kDefaultTimeout, CSocket::m_IsOwned, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, CSocket::r_timeout, SOCK_Close(), SOCK_CreateEx(), SOCK_ntoa(), SOCK_SetTimeout(), SOCK_Status(), SOCK_StringToHostPort(), and CSocket::w_timeout.
EIO_Status CDatagramSocket::Connect | ( | unsigned int | host, |
unsigned short | port | ||
) |
host | "host" is accepted in network byte order |
port | "port" is in host one |
Definition at line 459 of file ncbi_socket_cxx.cpp.
References DSOCK_Connect(), eIO_Unknown, CSocket::m_Socket, and SOCK_ntoa().
|
inlineprotected |
Definition at line 70 of file ncbi_socket.hpp.
CSocket::CSocket | ( | const string & | host, |
unsigned short | port, | ||
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Create a client-side socket connected to "host:port".
host | host name (or text IP address) of the host to connect to |
port | port number to connect at "host", always in host byte order |
timeout | maximal time to wait for connection to be established |
flags | additional socket properties (including logging) |
Definition at line 63 of file ncbi_socket_cxx.cpp.
References flags, kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, and SOCK_CreateEx().
CSocket::CSocket | ( | const string & | hostport, |
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Create a client-side socket connected to "host:port".
hostport | "host:port" as a string |
timeout | maximal time to wait for connection to be established |
flags | additional socket properties (including logging) |
Definition at line 79 of file ncbi_socket_cxx.cpp.
References flags, kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, SOCK_CreateEx(), SOCK_ntoa(), and SOCK_StringToHostPort().
CSocket::CSocket | ( | unsigned int | host, |
unsigned short | port, | ||
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Variant of the above, which takes host as a binary value in network byte order.
host | network byte order |
port | host byte order |
timeout | maximal time to wait for connection to be established |
flags | additional socket properties (including logging) |
Definition at line 103 of file ncbi_socket_cxx.cpp.
References flags, kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, SOCK_CreateEx(), and SOCK_ntoa().
|
inline |
CSocket::
Definition at line 882 of file ncbi_socket.hpp.
IMPLEMENTATION of INLINE functions.
CTrigger::
Definition at line 835 of file ncbi_socket.hpp.
References log, CTrigger::m_Trigger, and TRIGGER_Create().
|
inline |
IMPLEMENTATION of INLINE functions.
Definition at line 96 of file ncbi_socket_unix.hpp.
References flags, LSOCK_CreateUNIX(), and CListeningSocket::m_Socket.
|
inline |
Definition at line 69 of file ncbi_socket_unix.hpp.
CUNIXSocket::CUNIXSocket | ( | const string & | filename, |
const STimeout * | timeout = kInfiniteTimeout , |
||
TSOCK_Flags | flags = fSOCK_LogDefault |
||
) |
Definition at line 124 of file ncbi_socket_cxx.cpp.
References flags, kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, and SOCK_CreateUNIX().
|
inline |
Definition at line 52 of file ncbi_socket_unix.hpp.
on_off |
Definition at line 981 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_DisableOSSendDelay().
Referenced by CBDBEnvKeeperConnectionHandler::OnOpen(), CNetScheduleHandler::OnOpen(), CNetStorageHandler::OnOpen(), CWNCTConnectionHandler::OnOpen(), and CNetScheduleHandler::x_ProcessStatistics().
EIO_Status DSOCK_Bind | ( | SOCK | sock, |
unsigned short | port | ||
) |
Assosiate a datagram socket with a local port.
All other attempts to use the same port will result in eIO_Closed (for "port busy") unless SOCK_SetReuseAddress() is called, which then allows multiple sockets to bind to the same port, and receive messages, in undefined order, arriving at that port. Passing 0 will ask the OS to automatically choose an unused port, which then can be obtained via SOCK_GetLocalPort().
sock | [in] SOCK from DSOCK_Create[Ex]() |
port | [in] port to bind to (0 to auto-choose) |
Definition at line 8001 of file ncbi_socket.c.
References assert, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDefault, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Error, eLOG_Note, eLOG_Trace, eOn, eSOCK_Datagram, eSOCK_Server, in(), INADDR_ANY, SOCK_tag::log, MAXIDLEN, SOCK_tag::myport, s_DoLog(), s_ID(), s_Log, SOCK_tag::side, SOCK_tag::sock, SOCK_EADDRINUSE, SOCK_ERRNO, SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, and UTIL_ReleaseBuffer.
Referenced by CDatagramSocket::Bind().
EIO_Status DSOCK_Connect | ( | SOCK | sock, |
const char * | host, | ||
unsigned short | port | ||
) |
Associate a datagram socket with a destination address.
sock | [in] SOCK from DSOCK_Create[Ex]() |
host | [in] peer host |
port | [in] peer port |
Definition at line 8073 of file ncbi_socket.c.
References assert, BUF_Erase(), CONN_HOST_LEN, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDefault, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Error, eLOG_Note, SOCK_tag::eof, eOn, eSOCK_Datagram, SOCK_tag::host, SOCK_tag::id, SOCK_tag::log, MAXIDLEN, SOCK_tag::port, SOCK_tag::r_buf, SOCK_tag::r_len, s_DoLog(), s_gethostbyname(), s_ID(), s_Log, SOCK_tag::sock, SOCK_ERRNO, SOCK_HostPortToString(), SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, UTIL_ReleaseBuffer, SOCK_tag::w_buf, and SOCK_tag::w_len.
Referenced by CDatagramSocket::Connect().
EIO_Status DSOCK_Create | ( | SOCK * | sock | ) |
Same as DSOCK_CreateEx(, fSOCK_LogDefault)
sock | [out] socket created |
Definition at line 7857 of file ncbi_socket.c.
References DSOCK_CreateEx(), and fSOCK_LogDefault.
EIO_Status DSOCK_CreateEx | ( | SOCK * | sock, |
TSOCK_Flags | flags | ||
) |
Create a datagram socket.
sock | [out] socket created |
flags | [in] additional socket properties |
Definition at line 7863 of file ncbi_socket.c.
References BUF_SetChunkSize(), calloc(), CORE_LOGF_ERRNO_EXX, SOCK_tag::crossexec, eDefault, eIO_NotSupported, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Error, eLOG_Note, eLOG_Warning, eOn, eSOCK_Client, eSOCK_Datagram, SOCK_tag::event, flags, fSOCK_InterruptOnSignal, fSOCK_KeepOnClose, fSOCK_KeepOnExec, fSOCK_LogDefault, fSOCK_LogOn, fSOCK_Secure, HANDLE, SOCK_tag::i_on_sig, SOCK_tag::id, SOCK_tag::keep, SOCK_tag::log, MAXIDLEN, SOCK_tag::r_buf, s_DoLog(), s_ID(), s_InitAPI(), s_Log, s_SetCloexec(), s_SetNonblock(), s_WinStrerror(), SOCK_tag::side, SOCK_tag::sock, SOCK_BUF_CHUNK_SIZE, SOCK_CLOSE, SOCK_ERRNO, SOCK_EVENTS, SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, type, UTIL_ReleaseBuffer, UTIL_ReleaseBufferOnHeap(), SOCK_tag::w_buf, SOCK_tag::writable, and x_ID_Counter().
Referenced by CDatagramSocket::CDatagramSocket(), and DSOCK_Create().
TNCBI_BigCount DSOCK_GetMessageCount | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Get message count.
sock | [in] socket handle (datagram socket only) |
direction | [in] either eIO_Read (in) or eIO_Write (out) |
Definition at line 8409 of file ncbi_socket.c.
References assert, eIO_Read, eIO_Write, eSOCK_Datagram, SOCK_tag::n_in, SOCK_tag::n_out, and SOCK_tag::type.
Referenced by CDatagramSocket::GetMessageCount().
EIO_Status DSOCK_RecvMsg | ( | SOCK | sock, |
void * | buf, | ||
size_t | bufsize, | ||
size_t | maxmsglen, | ||
size_t * | msglen, | ||
unsigned int * | sender_addr, | ||
unsigned short * | sender_port | ||
) |
Receive a datagram from a datagram socket.
sock | [in] SOCK from DSOCK_Create[Ex]() |
buf | [in] buf to store msg at, may be NULL |
bufsize | [in] buf length provided |
maxmsglen | [in] maximal expected message len |
msglen | [out] actual msg size, may be NULL |
sender_addr | [out] net byte order, may be NULL |
sender_port | [out] host byte order, may be NULL |
Definition at line 8219 of file ncbi_socket.c.
References assert, buf, bufsize, CORE_LOGF_X, eIO_InvalidArg, eIO_Read, eIO_Success, eIO_Unknown, eLOG_Error, eSOCK_Datagram, eSOCK_ErrIO, SOCK_tag::host, info, MAXIDLEN, SOCK_tag::port, s_ErrHook, s_ErrorCallback(), s_ID(), s_RecvMsg(), SOCK_tag::sock, SOCK_INVALID, SOCK_ntoa(), and SOCK_tag::type.
Referenced by CDatagramSocket::Recv().
EIO_Status DSOCK_SendMsg | ( | SOCK | sock, |
const char * | host, | ||
unsigned short | port, | ||
const void * | data, | ||
size_t | datalen | ||
) |
Send a datagram to a datagram socket.
sock | [in] SOCK from DSOCK_Create[Ex]() |
host | [in] hostname or dotted IP |
port | [in] port number, host byte order |
data | [in] additional data to send |
datalen | [in] size of additional data (bytes) |
Definition at line 8272 of file ncbi_socket.c.
References assert, CORE_LOGF_X, data, eIO_InvalidArg, eIO_Success, eIO_Write, eLOG_Error, eSOCK_Datagram, eSOCK_ErrIO, SOCK_tag::host, info, MAXIDLEN, SOCK_tag::port, s_ErrHook, s_ErrorCallback(), s_ID(), s_SendMsg(), SOCK_tag::sock, SOCK_INVALID, SOCK_ntoa(), and SOCK_tag::type.
Referenced by CDatagramSocket::Send().
EIO_Status DSOCK_SetBroadcast | ( | SOCK | sock, |
int | broadcast | ||
) |
Set a datagram socket for broadcast.
sock | [in] SOCK from DSOCK_Create[Ex]() |
broadcast | [in] set(1)/unset(0) broadcast capability |
Definition at line 8361 of file ncbi_socket.c.
References assert, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_Unknown, eLOG_Error, eSOCK_Datagram, MAXIDLEN, s_ID(), SOCK_tag::sock, SOCK_ERRNO, SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, and UTIL_ReleaseBuffer.
Referenced by CDatagramSocket::SetBroadcast().
EIO_Status DSOCK_WaitMsg | ( | SOCK | sock, |
const STimeout * | timeout | ||
) |
Wait for a datagram in a datagram socket.
sock | [in] SOCK from DSOCK_Create[Ex]() |
timeout | [in] time to wait for message |
Definition at line 8170 of file ncbi_socket.c.
References assert, CORE_LOGF_X, eIO_Close, eIO_InvalidArg, eIO_Open, eIO_Read, eIO_Success, eIO_Timeout, eIO_Unknown, eLOG_Error, eSOCK_Datagram, eSOCK_ErrIO, SOCK_tag::host, info, MAXIDLEN, poll, SOCK_tag::port, s_ErrHook, s_ErrorCallback(), s_ID(), s_Select(), s_to2tv(), SOCK_tag::sock, SOCK_INVALID, SOCK_ntoa(), and SOCK_tag::type.
Referenced by CDatagramSocket::Wait().
EIO_Status DSOCK_WipeMsg | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Clear message froma datagram socket.
sock | [in] SOCK from DSOCK_Create[Ex]() |
direction | [in] either of eIO_Read (incoming), eIO_Write (outgoing) |
Definition at line 8315 of file ncbi_socket.c.
References assert, BUF_Erase(), CORE_LOGF_X, eIO_InvalidArg, eIO_Read, eIO_Success, eIO_Write, eLOG_Error, eSOCK_Datagram, MAXIDLEN, SOCK_tag::r_buf, SOCK_tag::r_len, SOCK_tag::r_status, s_ID(), SOCK_tag::sock, SOCK_INVALID, SOCK_tag::type, SOCK_tag::w_buf, and SOCK_tag::w_status.
Referenced by CDatagramSocket::Clear().
|
inline |
Definition at line 1030 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetCount().
Referenced by CNetScheduleHandler::OnClose(), and CNetStorageHandler::OnClose().
Return empty string on error.
Definition at line 670 of file ncbi_socket_cxx.cpp.
References log, SOCK_gethostbyaddrEx(), and string.
Referenced by CGridCommandLineInterfaceApp::Cmd_Discover(), g_DoPerfLogging(), g_NetService_gethostname(), g_NetService_gethostnamebyaddr(), g_NetService_TryResolveHost(), SSocketAddressImpl::GetName(), SNSNotificationAttributes::Print(), CNSClient::Print(), CNetScheduleAccessList::Print(), s_AppendCommonExtras(), CNSTClient::Serialize(), CJob::x_AppendEvents(), CJob::x_AppendListenerNotif(), CDBLBClientApp::x_RunWhatIs(), and CDBLBClientApp::x_RunWhereIs().
Return 0 on error.
Definition at line 679 of file ncbi_socket_cxx.cpp.
References kEmptyStr, log, and SOCK_gethostbynameEx().
Referenced by CNetScheduleKeyGenerator::CNetScheduleKeyGenerator(), CDBLB_ServiceMapper::ConfigureFromRegistry(), CConnTest::DnsOkay(), g_NetService_gethostbyname(), g_NetService_TryResolveHost(), GetAddressString(), SSocketAddressImpl::GetHost(), CGridWorkerNode::IsHostInAdminHostsList(), CNetCacheKey::KeyToCompoundID(), SGridWorkerNodeImpl::Run(), CNetScheduleAccessList::SetHosts(), CNetScheduleServer::SetNSParameters(), CDBLBClientApp::x_RunLookup(), and CDBLBClientApp::x_RunWhatIs().
Return empty string on error.
Definition at line 661 of file ncbi_socket_cxx.cpp.
References log, SOCK_gethostnameEx(), and string.
Referenced by CGetStatisticsProcessor::Process(), SGridWorkerNodeImpl::Run(), SetDiagUserAndHost(), CNetScheduleAccessList::SetHosts(), and CNetScheduleServer::SetNSParameters().
Local host address in network byte order (cached for faster retrieval)
Definition at line 1292 of file ncbi_socket.hpp.
References SOCK_GetLocalHostAddress().
Referenced by CDumpSysInfo::DumpSystemInfo(), SPSG_DiscoveryImpl::OnTimer(), and CNetScheduleHandler::x_PrintGetJobResponse().
|
inline |
Get socket local port number.
byte_order |
Definition at line 933 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetLocalPortEx().
Referenced by SNetScheduleNotificationReceiver::SNetScheduleNotificationReceiver().
|
inlinestatic |
Loopback address gets returned in network byte order.
Definition at line 1286 of file ncbi_socket.hpp.
References SOCK_GetLoopbackAddress().
Referenced by CNetScheduleHandler::x_GetPeerAddress(), and CNetStorageHandler::x_GetPeerAddress().
|
inline |
Access to the underlying "LSOCK".
Definition at line 1176 of file ncbi_socket.hpp.
References CListeningSocket::m_Socket.
Referenced by CSocketAPI::Poll().
|
inline |
Message count.
Definition at line 1110 of file ncbi_socket.hpp.
References DSOCK_GetMessageCount(), and CSocket::m_Socket.
|
inlinevirtual |
Access to the system-specific handle.
Implements CPollable.
Definition at line 865 of file ncbi_socket.hpp.
References eIO_NotSupported, and CTrigger::m_Trigger.
|
inlinevirtual |
Access to the system-specific socket handle.
handle_buf | |
handle_size |
Implements CPollable.
Definition at line 946 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetOSHandleEx().
Referenced by CNetCacheReader::SocketRead(), CNetScheduleHandler::x_SetQuickAcknowledge(), and CNetStorageHandler::x_SetQuickAcknowledge().
|
inlinevirtual |
Access to the system-specific socket handle.
handle_buf | |
handle_size |
Implements CPollable.
Definition at line 1152 of file ncbi_socket.hpp.
References LSOCK_GetOSHandleEx(), and CListeningSocket::m_Socket.
|
pure virtual |
Implemented in CListeningSocket, CSocket, and CTrigger.
string CSocket::GetPeerAddress | ( | ESOCK_AddressFormat | format = eSAF_Full | ) | const |
Get peer address as a text string.
Definition at line 403 of file ncbi_socket_cxx.cpp.
References buf, format, CSocket::m_Socket, PATH_MAX, SOCK_GetPeerAddressStringEx(), and string.
void CSocket::GetPeerAddress | ( | unsigned int * | host, |
unsigned short * | port, | ||
ENH_ByteOrder | byte_order | ||
) | const |
Get peer address.
host | |
port | |
byte_order |
Definition at line 389 of file ncbi_socket_cxx.cpp.
References CSocket::m_Socket, and SOCK_GetPeerAddress().
Referenced by SNSCommandArguments::AssignValues(), CRelocateCallback::Callback(), IServer_MessageHandler::OnRead(), CNetStorageHandler::OnRead(), SNetStorageObjectRPC::SIState::ReadConfirmation(), s_ReadMessage(), s_ReadSocket(), s_TrapErrors(), s_WriteToSocket(), SetSessionAndIPAndPHID(), CNetScheduleHandler::x_CreateConnContext(), CNetScheduleHandler::x_GetPeerAddress(), CNetStorageHandler::x_GetPeerAddress(), CNetScheduleHandler::x_HandleSocketErrorOnResponse(), CNetStorageHandler::x_OnSocketWriteError(), and CWNCTConnectionHandler::x_ProcessRequest().
|
inlinevirtual |
Implements CPollable.
Definition at line 107 of file ncbi_socket.hpp.
References CTrigger::m_Trigger, and POLLABLE_FromTRIGGER().
|
inlinevirtual |
Implements CPollable.
Definition at line 491 of file ncbi_socket.hpp.
References CSocket::m_Socket, and POLLABLE_FromSOCK().
|
inlinevirtual |
Implements CPollable.
Definition at line 707 of file ncbi_socket.hpp.
References CListeningSocket::m_Socket, and POLLABLE_FromLSOCK().
|
pure virtual |
Implemented in CListeningSocket, CSocket, and CTrigger.
|
inline |
Return port which the server listens on.
Definition at line 1162 of file ncbi_socket.hpp.
References LSOCK_GetPort(), and CListeningSocket::m_Socket.
|
inline |
Positions and stats (direction is either eIO_Read or eIO_Write).
Definition at line 1024 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetPosition().
|
inline |
Get socket remote port number.
byte_order |
Definition at line 940 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetRemotePort().
|
inline |
Access to the underlying "SOCK".
Definition at line 1050 of file ncbi_socket.hpp.
References CSocket::m_Socket.
Referenced by CSocketAPI::Poll(), s_GrabSOCK(), and CServer_Monitor::SetSocket().
|
inline |
Return status of *last* I/O operation without making any actual I/O.
direction | is one of
|
Definition at line 890 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_Status().
Referenced by CNetCacheWriter::AbortConnection(), SNetServerConnectionImpl::DeleteThis(), CServer_Monitor::IsMonitorActive(), CNetStorageHandler::OnRead(), CSocketAPI::Poll(), and SGridWorkerNodeImpl::x_AreMastersBusy().
|
inline |
Definition at line 841 of file ncbi_socket.hpp.
References eIO_Success, and CTrigger::m_Trigger.
|
inline |
Return eIO_Closed if not yet bound or Close()'d.
Definition at line 1146 of file ncbi_socket.hpp.
References eIO_Success, and CListeningSocket::m_Socket.
Referenced by CServer_Listener::Activate().
Get timeout for I/O in the specified direction.
Definition at line 319 of file ncbi_socket_cxx.cpp.
References CSocket::c_timeout, eIO_Close, eIO_Open, eIO_Read, eIO_ReadWrite, eIO_Write, kDefaultTimeout, CSocket::o_timeout, CSocket::r_timeout, STimeoutTag::sec, STimeoutTag::usec, and CSocket::w_timeout.
Referenced by CTimeoutKeeper::CTimeoutKeeper(), CSocketReaderWriter::GetTimeout(), CSocketReaderWriter::PendingCount(), SNetServerConnectionImpl::ReadCmdOutputLine(), and CServer_ConnectionPool::x_UpdateExpiration().
|
inline |
Definition at line 1036 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_GetTotalCount().
|
inline |
Access to the underlying "TRIGGER".
Definition at line 871 of file ncbi_socket.hpp.
References CTrigger::m_Trigger.
Referenced by CSocketAPI::Poll().
Definition at line 685 of file ncbi_socket_cxx.cpp.
References buf, len, SOCK_HostPortToString(), and string.
Referenced by CConnTest::CheckFWConnections(), GetAddressString(), CConnTest::GetFWConnections(), CDBLB_ServiceMapper::GetServerOptions(), and CDBLB_ServiceMapper::RecordServer().
Definition at line 1262 of file ncbi_socket.hpp.
References SOCK_HostToNetLong(), and rapidjson::value.
|
inlinestatic |
Definition at line 1274 of file ncbi_socket.hpp.
References SOCK_HostToNetShort(), and rapidjson::value.
Referenced by SNetServerInPool::SNetServerInPool(), and SUv_Connect::SUv_Connect().
|
inlinestatic |
|
inline |
Definition at line 1000 of file ncbi_socket.hpp.
References CSocket::m_Socket, SOCK_IsClientSide(), and true.
|
inline |
Definition at line 994 of file ncbi_socket.hpp.
References CSocket::m_Socket, SOCK_IsDatagram(), and true.
|
inline |
Definition at line 488 of file ncbi_socket.hpp.
References CSocket::m_Socket.
|
inline |
Definition at line 704 of file ncbi_socket.hpp.
References CListeningSocket::m_Socket.
Definition at line 1256 of file ncbi_socket.hpp.
References SOCK_isipEx(), and true.
Referenced by CNetScheduleKeyGenerator::CNetScheduleKeyGenerator(), GetAddressString(), and CNetCacheKey::KeyToCompoundID().
|
inline |
Definition at line 1018 of file ncbi_socket.hpp.
References CSocket::m_Socket, SOCK_IsSecure(), and true.
|
inline |
Definition at line 1006 of file ncbi_socket.hpp.
References CSocket::m_Socket, SOCK_IsServerSide(), and true.
|
inline |
Definition at line 853 of file ncbi_socket.hpp.
References eIO_Unknown, CTrigger::m_Trigger, and TRIGGER_IsSet().
|
inline |
Definition at line 1012 of file ncbi_socket.hpp.
References CSocket::m_Socket, SOCK_IsUNIX(), and true.
|
inline |
Definition at line 104 of file ncbi_socket_unix.hpp.
References eIO_Unknown, flags, LSOCK_CreateUNIX(), and CListeningSocket::m_Socket.
|
inline |
port | |
backlog | |
flags |
Definition at line 1137 of file ncbi_socket.hpp.
References eIO_Unknown, flags, LSOCK_CreateEx(), and CListeningSocket::m_Socket.
Referenced by CServer_Listener::Activate().
EIO_Status LSOCK_Accept | ( | LSOCK | lsock, |
const STimeout * | timeout, | ||
SOCK * | sock | ||
) |
[SERVER-side] Accept connection from a client.
Same as LSOCK_AcceptEx(.,.,.,fSOCK_LogDefault)
Definition at line 6538 of file ncbi_socket.c.
References fSOCK_LogDefault, and s_Accept().
EIO_Status LSOCK_AcceptEx | ( | LSOCK | lsock, |
const STimeout * | timeout, | ||
SOCK * | sock, | ||
TSOCK_Flags | flags | ||
) |
[SERVER-side] Accept connection from a client.
lsock | [in] handle of a listening socket |
timeout | [in] timeout (infinite if NULL) |
sock | [out] handle of the accepted socket |
flags | [in] properties for the accepted socket to have |
Definition at line 6546 of file ncbi_socket.c.
References flags, and s_Accept().
Referenced by CListeningSocket::Accept(), and x_FTPXfer().
EIO_Status LSOCK_Close | ( | LSOCK | lsock | ) |
[SERVER-side] Close the listening socket, destroy relevant internal data.
lsock | [in] listening socket handle to close The call invalidates the handle, so its further is not allowed. |
Definition at line 6555 of file ncbi_socket.c.
References eIO_InvalidArg, free(), s_CloseListening(), LSOCK_tag::sock, and SOCK_INVALID.
Referenced by CListeningSocket::Close(), x_FTPOpenData(), and x_FTPXfer().
EIO_Status LSOCK_Create | ( | unsigned short | port, |
unsigned short | backlog, | ||
LSOCK * | lsock | ||
) |
[SERVER-side] Create and initialize the server-side(listening) socket Same as LSOCK_CreateEx() called with the last argument provided as fSOCK_LogDefault.
port | [in] the port to listen at |
backlog | [in] maximal # of pending connections |
lsock | [out] handle of the created listening socket |
Definition at line 6507 of file ncbi_socket.c.
References fSOCK_LogDefault, and s_CreateListening().
EIO_Status LSOCK_CreateEx | ( | unsigned short | port, |
unsigned short | backlog, | ||
LSOCK * | lsock, | ||
TSOCK_Flags | flags | ||
) |
[SERVER-side] Create and initialize the server-side(listening) socket (socket() + bind() + listen())
port | [in] the port to listen at (0 to choose first available) |
backlog | [in] maximal # of pending connections |
lsock | [out] handle of the created listening socket |
flags | [in] special modifiers |
Definition at line 6516 of file ncbi_socket.c.
References flags, and s_CreateListening().
Referenced by CListeningSocket::CListeningSocket(), CListeningSocket::Listen(), and x_FTPActive().
EIO_Status LSOCK_CreateUNIX | ( | const char * | path, |
unsigned short | backlog, | ||
LSOCK * | lsock, | ||
TSOCK_Flags | flags | ||
) |
Definition at line 6526 of file ncbi_socket.c.
References eIO_InvalidArg, flags, and s_CreateListening().
Referenced by CUNIXListeningSocket::CUNIXListeningSocket(), and CUNIXListeningSocket::Listen().
EIO_Status LSOCK_GetOSHandle | ( | LSOCK | lsock, |
void * | handle_buf, | ||
size_t | handle_size | ||
) |
Same as LSOCK_GetOSHandleEx(lsock, handle_buf, handle_size, eNoOwnership).
Definition at line 6608 of file ncbi_socket.c.
References eNoOwnership, and LSOCK_GetOSHandleEx().
EIO_Status LSOCK_GetOSHandleEx | ( | LSOCK | lsock, |
void * | handle_buf, | ||
size_t | handle_size, | ||
EOwnership | owndership | ||
) |
Get an OS-dependent native socket handle to use by platform-specific API.
FYI: on MS-Windows it will be "SOCKET", on other platforms – "int".
lsock | [in] socket handle |
handle_buf | [in] pointer to a memory location to store the OS-dependent handle at |
handle_size | The exact(!) size of the expected OS handle |
ownership | eTakeOwnership removes the handle from LSOCK; eNoOwnership retains it |
Definition at line 6570 of file ncbi_socket.c.
References assert, CORE_LOGF_X, eIO_InvalidArg, eIO_Success, eLOG_Error, eTakeOwnership, LSOCK_tag::id, LSOCK_tag::keep, s_CloseListening(), s_Initialized, LSOCK_tag::sock, and SOCK_INVALID.
Referenced by CListeningSocket::GetOSHandle(), and LSOCK_GetOSHandle().
unsigned short LSOCK_GetPort | ( | LSOCK | lsock, |
ENH_ByteOrder | byte_order | ||
) |
Get socket port number, which it listens on.
The returned port is either one specified when the socket was created, or an automatically assigned number if LSOCK_Create() provided the port as 0.
lsock | [in] socket handle |
byte_order | [in] byte order for port on return |
Definition at line 6616 of file ncbi_socket.c.
References eNH_HostByteOrder, LSOCK_tag::port, LSOCK_tag::sock, and SOCK_INVALID.
Referenced by CListeningSocket::GetPort(), x_FTPActive(), and x_FTPXfer().
NCBI_CRED NcbiCreateTlsCertCredentials | ( | const void * | cert, |
size_t | certsz, | ||
const void * | pkey, | ||
size_t | pkeysz | ||
) |
Build NCBI_CRED from memory buffers containing X.509 certificate and private key, respectively, in either PEM or DER format (independently of each other).
The returned credentials handle must not be deleted while it's in use.
If a size is passed as 0, the corresponding pointer argument is assumed to be a '\0'-terminated string, and the size gets computed internally as strlen(ptr) + 1, to cover the trailing '\0' byte, see below.
To figure out the format of cert / key, the passed buffer gets analyzed to see whether the last byte is '\0' and whether the therefore properly terminated C-string happens to contain a "-----BEGIN " substring: if both conditions are true, then the buffer is considered in PEM format; or DER, otherwise.
Definition at line 120 of file ncbi_tls.c.
References CORE_LOG_X, CORE_LOGF_X, eLOG_Critical, eLOG_Error, eLOG_Warning, eNcbiCred_GnuTls, eNcbiCred_MbedTls, NcbiCreateMbedTlsCertCredentials(), NcbiSetupGnuTls(), NcbiSetupMbedTls(), setup(), SOCK_SSLName(), util::strcmp(), and x_NcbiSetupTls().
Referenced by CTlsCertCredentials::GetNcbiCred().
NCBI_CRED NcbiCredGnuTls | ( | void * | xcred | ) |
Convert a native GNUTLS certificate credentials' handle into an abstract toolkit handle.
Definition at line 911 of file ncbi_gnutls.c.
References calloc(), SNcbiCred::data, eNcbiCred_GnuTls, and SNcbiCred::type.
NCBI_CRED NcbiCredMbedTls | ( | void * | xcert, |
void * | xpkey | ||
) |
Convert native mbedTLS certificate credentials' handles into an abstract toolkit handle.
Two arguments are _required_: a pointer to a parsed certificate (xcert), and a pointer to a parsed private key (xpkey).
Definition at line 882 of file ncbi_mbedtls.c.
References ALIGN, calloc(), SNcbiMbedTlsCred::cert, SNcbiCred::data, eNcbiCred_MbedTls, SNcbiMbedTlsCred::pkey, ncbi::grid::netcache::search::fields::size, and SNcbiCred::type.
void NcbiDeleteTlsCertCredentials | ( | NCBI_CRED | cred | ) |
Delete a NCBI_CRED handle created by NcbiCreateTlsCertCredentials().
Definition at line 180 of file ncbi_tls.c.
References CORE_LOGF_X, SNcbiCred::data, eLOG_Error, eNcbiCred_GnuTls, eNcbiCred_MbedTls, free(), NcbiDeleteMbedTlsCertCredentials(), and SNcbiCred::type.
Referenced by CTlsCertCredentials::~CTlsCertCredentials().
SOCKSSL NcbiSetupGnuTls | ( | void | ) |
Explicitly setup GNUTLS library to support SSL in ncbi_socket.h[pp].
Definition at line 888 of file ncbi_gnutls.c.
References CORE_LOG_X, eLOG_Warning, and s_GnuTlsInit().
Referenced by NcbiCreateTlsCertCredentials(), and x_NcbiSetupTls().
SOCKSSL NcbiSetupMbedTls | ( | void | ) |
Explicitly setup mbedTLS library to support SSL in ncbi_socket.h[pp].
Definition at line 855 of file ncbi_mbedtls.c.
References CORE_LOG_X, eLOG_Warning, s_MbedTlsClose(), s_MbedTlsCreate(), s_MbedTlsDelete(), s_MbedTlsError(), s_MbedTlsExit(), s_MbedTlsInit(), s_MbedTlsOpen(), s_MbedTlsRead(), and s_MbedTlsWrite().
Referenced by NcbiCreateTlsCertCredentials(), and x_NcbiSetupTls().
SOCKSSL NcbiSetupTls | ( | void | ) |
Setup a TLS (Transport Layer Security) provider library to support SSL in ncbi_socket.h[pp].
Currently we support mbedTLS and GNUTLS as the providers. This call selects a library, which is either the default or requested via the registry (aka .ini file), or through the process environment (takes precedence over the registry):
[CONN] USESSL={1,0,MBEDTLS,GNUTLS}
CONN_USESSL={1,0,MBEDTLS,GNUTLS}
"Off", "No", "False", case-insensitively, are also accepted for "0"; and "On", "Yes", "True" – for "1".
If no provider is present in the build, "0" is assumed. "1" selects the default provider as currently configured within the toolkit. With "0", SSL will not be availbale for sockets, and any secure session will fail.
Definition at line 113 of file ncbi_tls.c.
References setup(), and x_NcbiSetupTls().
Referenced by CConnIniter::CConnIniter(), and CONNECT_Init().
Definition at line 1268 of file ncbi_socket.hpp.
References SOCK_NetToHostLong, and rapidjson::value.
Referenced by SNetServerInPool::SNetServerInPool().
|
inlinestatic |
Definition at line 1280 of file ncbi_socket.hpp.
References SOCK_NetToHostShort, and rapidjson::value.
Referenced by SUv_Tcp::OnConnect().
BSD-like API. NB: when int, "host" must be in network byte order.
Definition at line 652 of file ncbi_socket_cxx.cpp.
References SOCK_ntoa(), and string.
Referenced by CGridCommandLineInterfaceApp::Cmd_Discover(), CReaderServiceConnector::Connect(), SNetServerImpl::ConnectImpl(), CDumpSysInfo::DumpSystemInfo(), SNetCacheAPIImpl::ExecMirrorAware(), g_NetService_gethostip(), g_NetService_gethostnamebyaddr(), CEUtils_Request::GetBaseURL(), SSocketAddressImpl::GetName(), CDBLB_ServiceMapper::GetServersList(), CNSNotificationList::NotifyJobChanges(), operator<<(), CNetCacheKey::ParseBlobKey(), CNetScheduleKey::ParseJobKey(), CDatagramSocket::Recv(), CReaderServiceConnector::RememberIfBad(), s_DumpCompoundID(), CNetScheduleServer::SetNSParameters(), CEutilsClient::x_GetHostName(), CNetScheduleHandler::x_PrintGetJobResponse(), CDBLBClientApp::x_RunWhatIs(), and CNSNotificationList::x_SendNotificationPacket().
|
inlinestatic |
Definition at line 1205 of file ncbi_socket.hpp.
References SOCK_OSHandleSize().
|
static |
Poll a vector of CPollable objects for I/O readiness.
Definition at line 590 of file ncbi_socket_cxx.cpp.
References eIO_Close, eIO_Open, eIO_Unknown, SPOLLABLE_Poll::event, CListeningSocket::GetLSOCK(), CSocket::GetSOCK(), CSocket::GetStatus(), CTrigger::GetTRIGGER(), i, SPOLLABLE_Poll::poll, POLLABLE_FromLSOCK(), POLLABLE_FromSOCK(), POLLABLE_FromTRIGGER(), POLLABLE_Poll(), and SPOLLABLE_Poll::revent.
Referenced by CConnTest::CheckFWConnections(), CNetCacheWriter::TransmitImpl(), and CServer::x_DoRun().
Definition at line 8620 of file ncbi_socket.c.
References assert, eSOCK_Listening, and LSOCK_tag::type.
Referenced by CListeningSocket::GetPOLLABLE(), and CSocketAPI::Poll().
Conversion utilities from handles to POLLABLEs, and back.
Definition at line 8627 of file ncbi_socket.c.
References assert, eSOCK_Socket, and SOCK_tag::type.
Referenced by CSocket::GetPOLLABLE(), and CSocketAPI::Poll().
Definition at line 8613 of file ncbi_socket.c.
References assert, eSOCK_Trigger, and TRIGGER_tag::type.
Referenced by CTrigger::GetPOLLABLE(), and CSocketAPI::Poll().
EIO_Status POLLABLE_Poll | ( | size_t | n, |
SPOLLABLE_Poll | polls[], | ||
const STimeout * | timeout, | ||
size_t * | n_ready | ||
) |
Poll for I/O readiness.
n | [in] how many elements to scan in the "polls" array parameter |
polls[] | [in/out] array of handles and event masks to check for I/O, and return |
timeout | [in] how long to wait for at least one handle to get ready. |
n_ready | [out] how many elements of the "polls" array returned with their I/O marked ready |
Definition at line 8597 of file ncbi_socket.c.
References n, and SOCK_Poll().
Referenced by CSocketAPI::Poll().
Definition at line 8641 of file ncbi_socket.c.
References eSOCK_Listening, poll, and LSOCK_tag::type.
Definition at line 8648 of file ncbi_socket.c.
References eSOCK_Socket, poll, and SOCK_tag::type.
Definition at line 8634 of file ncbi_socket.c.
References eSOCK_Trigger, poll, and TRIGGER_tag::type.
ESOCK_Type POLLABLE_What | ( | POLLABLE | poll | ) |
Identifies a non-NULL POLLABLE.
Definition at line 8606 of file ncbi_socket.c.
|
inline |
Push back data to socket (to be read out first).
buf | |
size |
Definition at line 914 of file ncbi_socket.hpp.
References buf, CSocket::m_Socket, ncbi::grid::netcache::search::fields::size, and SOCK_Pushback().
Referenced by CSocketReaderWriter::Pushback().
EIO_Status CSocket::Read | ( | void * | buf, |
size_t | size, | ||
size_t * | n_read = 0 , |
||
EIO_ReadMethod | how = eIO_ReadPlain |
||
) |
Read from socket.
buf | |
size | |
n_read | |
how |
Definition at line 345 of file ncbi_socket_cxx.cpp.
References buf, CSocket::m_Socket, ncbi::grid::netcache::search::fields::size, and SOCK_Read().
Referenced by IServer_MessageHandler::OnRead(), CNetStorageHandler::OnRead(), CSocketReaderWriter::PendingCount(), CSocketReaderWriter::Read(), s_ReadSocket(), and CNetCacheReader::SocketRead().
|
inline |
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs).
buf | |
size | |
n_read |
Definition at line 908 of file ncbi_socket.hpp.
References buf, CSocket::m_Socket, ncbi::grid::netcache::search::fields::size, and SOCK_ReadLine().
EIO_Status CSocket::ReadLine | ( | string & | str | ) |
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs).
str |
Definition at line 358 of file ncbi_socket_cxx.cpp.
References buf, eIO_Success, CSocket::m_Socket, ncbi::grid::netcache::search::fields::size, SOCK_ReadLine(), and str().
Referenced by SNetServerConnectionImpl::ReadCmdOutputLine(), CNetCacheWriter::TransmitImpl(), and SGridWorkerNodeImpl::x_AreMastersBusy().
|
protected |
EIO_Status CSocket::Reconnect | ( | const STimeout * | timeout = kDefaultTimeout | ) |
Reconnect to the same address.
timeout | maximal time to reconnect |
Definition at line 247 of file ncbi_socket_cxx.cpp.
References kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, and SOCK_Reconnect().
EIO_Status CDatagramSocket::Recv | ( | void * | buf, |
size_t | buflen, | ||
size_t * | msglen = 0 , |
||
string * | sender_host = 0 , |
||
unsigned short * | sender_port = 0 , |
||
size_t | maxmsglen = 0 |
||
) |
buf | |
buflen | |
msglen | |
sender_host | |
sender_port | |
maxmsglen |
Definition at line 487 of file ncbi_socket_cxx.cpp.
References buf, DSOCK_RecvMsg(), CSocket::m_Socket, and CSocketAPI::ntoa().
Referenced by SNetScheduleNotificationReceiver::operator()().
void CSocket::Reset | ( | SOCK | sock, |
EOwnership | if_to_own, | ||
ECopyTimeout | whence | ||
) |
Close the current underlying "SOCK" (if any, and if owned), and from now on use "sock" as the underlying "SOCK" instead.
sock | |
if_to_own | |
whence |
Definition at line 414 of file ncbi_socket_cxx.cpp.
References CSocket::c_timeout, CSocket::cc_timeout, eCopyTimeoutsFromSOCK, eIO_Close, eIO_Read, eIO_Write, eNoOwnership, CSocket::m_IsOwned, CSocket::m_Socket, CSocket::r_timeout, CSocket::rr_timeout, SOCK_Close(), SOCK_GetTimeout(), SOCK_SetTimeout(), CSocket::w_timeout, and CSocket::ww_timeout.
Referenced by CListeningSocket::Accept(), CConn_IOStream::Close(), CConn_IOStream::GetSocket(), s_GrabSOCK(), and CServer_Monitor::SetSocket().
|
inline |
Definition at line 859 of file ncbi_socket.hpp.
References eIO_Unknown, CTrigger::m_Trigger, and TRIGGER_Reset().
Referenced by CServer::x_DoRun().
|
inline |
data | |
datalen | |
host | |
port | host byte order |
Definition at line 1081 of file ncbi_socket.hpp.
References data, DSOCK_SendMsg(), and CSocket::m_Socket.
Referenced by CGridGlobals::InterruptUDPPortListening(), CNSNotificationList::NotifyJobChanges(), CNSNotificationList::x_SendNotificationPacket(), and SNetScheduleAPIImpl::~SNetScheduleAPIImpl().
|
inline |
Definition at line 847 of file ncbi_socket.hpp.
References eIO_Unknown, CTrigger::m_Trigger, and TRIGGER_Set().
Referenced by CServer_ConnectionPool::PingControlConnection().
|
inline |
do_broadcast |
Definition at line 1104 of file ncbi_socket.hpp.
References DSOCK_SetBroadcast(), and CSocket::m_Socket.
on_off |
Definition at line 974 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_SetCork().
Referenced by CNetCacheWriter::Close(), and CNetCacheWriter::EstablishConnection().
log |
Definition at line 1250 of file ncbi_socket.hpp.
References log, and SOCK_SetDataLoggingAPI().
log |
Definition at line 988 of file ncbi_socket.hpp.
References eDefault, log, CSocket::m_Socket, and SOCK_SetDataLogging().
Referenced by SNetScheduleNotificationReceiver::SNetScheduleNotificationReceiver().
interrupt |
Definition at line 1238 of file ncbi_socket.hpp.
References SOCK_SetInterruptOnSignalAPI().
interrupt |
Definition at line 961 of file ncbi_socket.hpp.
References eDefault, CSocket::m_Socket, and SOCK_SetInterruptOnSignal().
|
inlinestatic |
Definition at line 1225 of file ncbi_socket.hpp.
References SOCK_SetIOWaitSysAPI().
|
inline |
Specify if this "CSocket" is to own the underlying "SOCK".
if_to_own |
Definition at line 1042 of file ncbi_socket.hpp.
References CSocket::m_IsOwned.
Referenced by s_GrabSOCK(), and CServer_Monitor::SetSocket().
|
inline |
Specify if this "CListeningSocket" is to own the underlying "LSOCK".
if_to_own |
Definition at line 1168 of file ncbi_socket.hpp.
References CListeningSocket::m_IsOwned.
Defaults (see also per-socket CSocket::SetReadOnWrite, etc.)
read_on_write |
Definition at line 1232 of file ncbi_socket.hpp.
References SOCK_SetReadOnWriteAPI().
read_on_write |
Definition at line 955 of file ncbi_socket.hpp.
References eDefault, CSocket::m_Socket, and SOCK_SetReadOnWrite().
reuse |
Definition at line 1244 of file ncbi_socket.hpp.
References SOCK_SetReuseAddressAPI().
reuse |
Definition at line 967 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_SetReuseAddress().
|
inlinestatic |
Utility.
Definition at line 1218 of file ncbi_socket.hpp.
References SOCK_SetSelectInternalRestartTimeout().
EIO_Status CSocket::SetTimeout | ( | EIO_Event | event, |
const STimeout * | timeout | ||
) |
Set timeout for I/O in the specified direction.
event | either of eIO_Open, eIO_Read, eUI_Write, eIO_ReadWrite, or eIO_Close |
timeout | new value to set (including special kInfiniteTimeout) |
Definition at line 261 of file ncbi_socket_cxx.cpp.
References CSocket::c_timeout, CSocket::cc_timeout, eIO_Close, eIO_InvalidArg, eIO_Open, eIO_Read, eIO_ReadWrite, eIO_Success, eIO_Write, kDefaultTimeout, CSocket::m_Socket, CSocket::o_timeout, CSocket::oo_timeout, CSocket::r_timeout, CSocket::rr_timeout, SOCK_SetTimeout(), CSocket::w_timeout, and CSocket::ww_timeout.
Referenced by CTimeoutKeeper::CTimeoutKeeper(), CNetScheduleHandler::OnOpen(), CNetStorageHandler::OnOpen(), CSocketReaderWriter::PendingCount(), CSocketReaderWriter::SetTimeout(), SNetScheduleNotificationReceiver::SNetScheduleNotificationReceiver(), SNetServerConnectionImpl::SNetServerConnectionImpl(), CServer_Connection::~CServer_Connection(), and CTimeoutKeeper::~CTimeoutKeeper().
|
inline |
Shutdown socket I/O in the specified direction.
how | either of eIO_Read, eIO_Write, or eIO_ReadWrite |
Definition at line 896 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_Shutdown().
Referenced by CNetScheduleHandler::OnClose(), and CNetStorageHandler::OnClose().
|
protected |
|
inlinestatic |
Definition at line 1193 of file ncbi_socket.hpp.
References SOCK_ShutdownAPI().
EIO_Status SOCK_Abort | ( | SOCK | sock | ) |
If there is outstanding connection or output data pending, cancel it.
Mark the socket as if it has been shut down for both reading and writing. Break actual connection if any was established. Do not attempt to send anything upon SOCK_Close(). This call is available for stream sockets only.
sock | [in] socket handle |
Definition at line 7557 of file ncbi_socket.c.
References assert, CORE_LOGF_X, eIO_InvalidArg, eLOG_Error, eLOG_Warning, eSOCK_Datagram, fSOCK_KeepNone, MAXIDLEN, s_Close_(), s_ID(), SOCK_tag::sock, SOCK_INVALID, and SOCK_tag::type.
Referenced by CSocket::Abort(), CListeningSocket::Accept(), s_Connect(), s_DropConnection(), s_SocketConnectorBuilder(), s_VT_Close(), s_VT_Open(), x_FTPCloseCntl(), x_FTPCloseData(), and x_URLConnectErrorReturn().
void SOCK_AllowSigPipeAPI | ( | void | ) |
By default (on UNIX platforms) the SOCK API functions automagically call "signal(SIGPIPE, SIG_IGN)" on initialization.
To prohibit this feature you must call SOCK_AllowSigPipeAPI() before you call any other function from the SOCK API.
Definition at line 1060 of file ncbi_socket.c.
References s_AllowSigPipe.
Referenced by CSocketAPI::AllowSigPipe().
EIO_Status SOCK_Close | ( | SOCK | sock | ) |
Close the SOCK handle, and destroy all relevant internal data.
The "sock" handle goes invalid after this function call, regardless of whether the call was successful or not. If eIO_Close timeout was specified (or NULL) then it blocks until either all unsent data are sent, an error flagged, or the timeout expires; if there was any output pending, that output will be flushed. Connection may remain in the system if SOCK was created with the fSOCK_KeepOnClose flag set; otherwise, it gets closed as well.
sock | [in] socket handle to close(if not yet closed) and destroy(always) |
Definition at line 6851 of file ncbi_socket.c.
References SOCK_CloseEx().
Referenced by CListeningSocket::Accept(), CUNIXSocket::Connect(), CSocket::Connect(), CORE_SendMailEx(), LBSM_SubmitPenaltyOrRerate(), ProcessOverflow(), CDBLB_ServiceMapper::RecordServer(), CSocket::Reset(), s_DropConnection(), s_SocketConnectorBuilder(), s_VT_Close(), s_VT_Open(), x_FTPCloseCntl(), x_FTPCloseData(), x_URLConnectErrorReturn(), and CSocket::~CSocket().
EIO_Status SOCK_CloseEx | ( | SOCK | sock, |
int | destroy | ||
) |
Close the SOCK handle, and conditionally destroy relevant internal data.
If eIO_Close timeout was specified (or NULL) then it blocks until either all unsent data are sent, an error flagged, or the timeout expires; if there is any output pending, that output will be flushed. Connection may remain in the system if the socket was created with the fSOCK_KeepOnClose flag set; otherwise, it gets closed as well.
sock | [in] handle of the socket to close |
destroy | [in] =1 to destroy the SOCK handle; =0 to keep the handle |
Definition at line 6857 of file ncbi_socket.c.
References assert, BUF_Destroy(), BUF_Erase(), destroy(), eIO_InvalidArg, eIO_Success, free(), fSOCK_KeepNone, SNcbiSSLctx::host, SOCK_tag::r_buf, s_Close(), s_Initialized, SNcbiSSLctx::sess, SOCK_tag::sock, SOCK_INVALID, SOCK_tag::sslctx, and SOCK_tag::w_buf.
Referenced by CSocket::Close(), and SOCK_Close().
EIO_Status SOCK_CloseOSHandle | ( | const void * | handle, |
size_t | handle_size | ||
) |
Close socket OS handle (ungracefully aborting the connection if necessary).
The call retries repeatedly if interrupted by a singal (so no eIO_Interrupt should be expected). Return eIO_Success when the handle has been closed successfully, eIO_Closed if the handle has been passed already closed, eIO_InvalidArg if passed arguments are not valid, eIO_Unknown if the handle cannot be closed (per an error returned by the system, see errno).
Definition at line 6890 of file ncbi_socket.c.
References eIO_InvalidArg, eIO_Success, eIO_Timeout, eIO_Unknown, lgr(), s_Initialized, SOCK_CLOSE, SOCK_ECONNABORTED, SOCK_ECONNRESET, SOCK_EINTR, SOCK_ENETRESET, SOCK_ENOTCONN, SOCK_ERRNO, SOCK_ETIMEDOUT, and SOCK_INVALID.
Referenced by CSocketAPI::CloseOSHandle().
EIO_Status SOCK_Create | ( | const char * | host, |
unsigned short | port, | ||
const STimeout * | timeout, | ||
SOCK * | sock | ||
) |
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()]) Equivalent to SOCK_CreateEx(host, port, timeout, sock, 0, 0, fSOCK_LogDefault).
host | [in] host to connect to |
port | [in] port to connect to |
timeout | [in] the connect timeout (infinite if NULL) |
sock | [out] handle of the created socket |
Definition at line 6664 of file ncbi_socket.c.
References fSOCK_LogDefault, and SOCK_CreateInternal().
EIO_Status SOCK_CreateEx | ( | const char * | host, |
unsigned short | port, | ||
const STimeout * | timeout, | ||
SOCK * | sock, | ||
const void * | data, | ||
size_t | size, | ||
TSOCK_Flags | flags | ||
) |
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()])
host | [in] host to connect to |
port | [in] port to connect to |
timeout | [in] the connect timeout (infinite if NULL) |
sock | [out] handle of socket created |
data | [in] initial output data block (may be NULL) |
size | [in] size of the initial data block (may be 0) |
flags | [in] additional socket requirements |
Definition at line 6648 of file ncbi_socket.c.
References data, flags, init(), ncbi::grid::netcache::search::fields::size, and SOCK_CreateInternal().
Referenced by CSocket::Connect(), CORE_SendMailEx(), CSocket::CSocket(), s_VT_Open(), and x_FTPPassive().
EIO_Status SOCK_CreateOnTop | ( | const void * | handle, |
size_t | handle_size, | ||
SOCK * | sock | ||
) |
[SERVER-side] Create a socket on top of a "handle".
Equivalent to SOCK_CreateOnTopEx(handle, handle_size, sock, 0, 0, fSOCK_LogDefault|fSOCK_CloseOnClose).
handle | [in] OS-dependent "handle" or "SOCK" to be converted |
handle_size | [in] "handle" size (0 if a "SOCK" passed in "handle") |
sock | [out] SOCK built on top of the OS "handle" |
Definition at line 6730 of file ncbi_socket.c.
References fSOCK_LogDefault, and SOCK_CreateOnTopInternal().
EIO_Status SOCK_CreateOnTopEx | ( | const void * | handle, |
size_t | handle_size, | ||
SOCK * | sock, | ||
const void * | data, | ||
size_t | size, | ||
TSOCK_Flags | flags | ||
) |
[SERVER-side] Create a SOCKet on top of either an OS-dependent "handle" (file descriptor on Unix, SOCKET on MS-Windows) or an existing SOCK object.
In the former case, the returned socket is not reopenable to its default peer (SOCK_Reconnect() may not specify zeros for the connection point). In the latter case, the returned socket is reopenable to its default peer only if the original existing socket is a client-side one (connected to a remote server end), not a server-side socket (accepted at the server end). All timeouts are set to default [infinite] values. The call does *not* destroy either the OS handle or the SOCK passed in the arguments, regardless of the return status code. When a socket is being created on top of a SOCK handle, the original SOCK gets emptied (and the underlying OS handle removed from it) upon the call return (whether successfully or not), yet it will still need SOCK_Destroy() in the caller's code to free up the memory it occupies. Any secure session that may have existed in the original SOCK will have been migrated to the new socket iff "flags" indicate fSOCK_Secure (if no session existed, a new session may have been initiated in the new SOCK). Otherwise, the original secure session (if any) will have been closed. Any pending output will have been flushed (if switching secure / insecure contexts; otherwise, it will have simply migrated to the created SOCK), and any pending input still in the original SOCK will migrate to the new socket object returned. If this behavior is undesireable, one can use SOCK_GetOSHandleEx() on the original socket, taking the ownership of the underlying OS handle, and then create a SOCK on top of the bare "handle", specifying its (non-zero) "handle_size".
handle | [in] OS-dependent "handle" or SOCK to be converted |
handle_size | [in] "handle" size (or 0 if a SOCK passed in "handle") |
sock | [out] SOCK built on top of the "handle" |
data | [in] initial output data block (may be NULL) |
size | [in] size of the initial data block (may be 0) |
flags | [in] additional socket requirements |
Definition at line 6714 of file ncbi_socket.c.
References data, flags, init(), ncbi::grid::netcache::search::fields::size, and SOCK_CreateOnTopInternal().
Referenced by CDBLB_ServiceMapper::RecordServer().
EIO_Status SOCK_CreateUNIX | ( | const char * | path, |
const STimeout * | timeout, | ||
SOCK * | sock, | ||
const void * | data, | ||
size_t | size, | ||
TSOCK_Flags | flags | ||
) |
Definition at line 6673 of file ncbi_socket.c.
References assert, data, eIO_InvalidArg, eIO_NotSupported, eIO_Success, flags, init(), s_Create(), and ncbi::grid::netcache::search::fields::size.
Referenced by CUNIXSocket::Connect(), CUNIXSocket::CUNIXSocket(), and LBSM_SubmitPenaltyOrRerate().
Control OS-defined send strategy by disabling/enabling the TCP Nagle algorithm (which is on by default) that packs multiple requests into a single packet and thus transfers the data in fewer transactions, miminizing the network traffic and generally bursting the throughput.
However, some applications may find it useful to disable this default behavior for the sake of their performance increase (like in case of short transactions otherwise held off by the system in anticipation of coalescing into larger chunks – a typical example is an interactive transmission of keystrokes). Disabling the Nagle algorithm causes all internally pending yet untransmitted data to flush down to the hardware.
sock | [in] socket handle [stream socket only] |
on_off | [in] 1 to disable the send delay; 0 to enable the send delay |
Definition at line 7815 of file ncbi_socket.c.
References assert, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eLOG_Error, eLOG_Warning, eSOCK_Datagram, MAXIDLEN, s_ID(), SOCK_tag::sock, SOCK_ERRNO, SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, and UTIL_ReleaseBuffer.
Referenced by CORE_SendMailEx(), CSocket::DisableOSSendDelay(), s_VT_Open(), and URL_ConnectEx().
TNCBI_BigCount SOCK_GetCount | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Get counts of read or written bytes.
sock | [in] socket handle |
direction | [in] either eIO_Read or eIO_Write |
Definition at line 8492 of file ncbi_socket.c.
References assert, eIO_Read, eIO_Write, eSOCK_Datagram, SOCK_tag::n_read, SOCK_tag::n_written, SOCK_tag::r_len, SOCK_tag::type, and SOCK_tag::w_len.
Referenced by CSocket::GetCount(), and x_FTPCloseData().
Same as SOCK_gethostbyaddrEx(,,<current API data logging>)
Definition at line 8813 of file ncbi_socket.c.
References buf, bufsize, s_Log, and SOCK_gethostbyaddrEx().
Referenced by ConnNetInfo_SetupStandardArgs(), CORE_SendMailEx(), s_MakeFrom(), s_SysGetDomainName(), x_RedirectOK(), x_SameProxyHost(), and x_SetDefaultReferer().
Take IPv4 host address (in network byte order) or 0 for current host, and fill out the provided buffer with the name, which the address corresponds to (in case of multiple names the primary name is used).
addr | [in] IPv4 host address (0 means current host) in network byte order |
name | [out] buffer to store the name to |
namelen | [in] size (bytes) of the buffer above |
log | [in] whether to log failures |
Definition at line 8796 of file ncbi_socket.c.
References assert, buf, bufsize, eDefault, eIO_Success, log, s_gethostbyaddr(), s_InitAPI(), and s_Log.
Referenced by CSocketAPI::gethostbyaddr(), and SOCK_gethostbyaddr().
Same as SOCK_gethostbynameEx(,<current API data logging>)
Definition at line 8790 of file ncbi_socket.c.
References s_Log, and SOCK_gethostbynameEx().
Referenced by DBLB_GetServer(), NcbiParseIPRange(), s_ParseHeader(), SERV_LBDNS_Open(), x_ClientAddress(), x_RedirectOK(), x_SameProxyHost(), and x_StringToAddr().
Find and return IPv4 address of a named host.
The call also accepts dotted IPv4 notation, in which case the conversion is done without consulting the name resolver (DNS).
hostname | [in] specified host, or the current host if hostname is either 0 or "" |
log | [in] whether to log failures |
Definition at line 8780 of file ncbi_socket.c.
References eDefault, eIO_Success, log, s_gethostbyname(), s_InitAPI(), and s_Log.
Referenced by CSocketAPI::gethostbyname(), s_Resolve(), and SOCK_gethostbyname().
int SOCK_gethostname | ( | char * | name, |
size_t | namelen | ||
) |
Same as SOCK_gethostnameEx(,,<current API data logging>)
Definition at line 8774 of file ncbi_socket.c.
References buf, bufsize, s_Log, and SOCK_gethostnameEx().
Referenced by ConnNetInfo_SetupStandardArgs(), CORE_SendMailEx(), s_MakeFrom(), and x_SetDefaultReferer().
Get the local host name.
name | [out] (guaranteed to be '\0'-terminated) |
namelen | [in] max # of bytes allowed to put into "name" |
log | [in] whether to log failures |
Definition at line 8760 of file ncbi_socket.c.
References assert, buf, bufsize, eDefault, eIO_Success, log, s_gethostname(), s_InitAPI(), and s_Log.
Referenced by CSocketAPI::gethostname(), and SOCK_gethostname().
Get (and cache for faster follow-up retrievals) IPv4 address of local host.
reget | eOn to forcibly re-cache and return the address; eDefault to re-cache only if unknown, return the [new] cached value; eOff not to re-cache even if unknown, return whatever is available. |
Definition at line 8827 of file ncbi_socket.c.
References eIO_Success, s_getlocalhostaddress(), s_InitAPI(), and s_Log.
Referenced by g_NCBI_ConnectSrandAddend(), CSocketAPI::GetLocalHostAddress(), LBSMD_GetLocalHostAddress(), s_IsSkipHost(), s_LoadSingleService(), SERV_ServerPort(), x_ClientAddress(), x_FTPActive(), and x_Open().
unsigned short SOCK_GetLocalPort | ( | SOCK | sock, |
ENH_ByteOrder | byte_order | ||
) |
Get local port of the socket.
The returned port number is also cached within "sock" so any further inquires for the local port do not cause any system calls to occur. The call is exactly equavalent to SOCK_GetLocalPortEx(sock, 0, byte_order).
sock | [in] socket handle |
byte_order | [in] byte order for port on return |
Definition at line 7605 of file ncbi_socket.c.
References SOCK_GetLocalPortEx().
unsigned short SOCK_GetLocalPortEx | ( | SOCK | sock, |
int | trueport, | ||
ENH_ByteOrder | byte_order | ||
) |
Get local port of the socket (true or cached / stored).
For most users, a simpler SOCK_GetLocalPort() call is going to be the most suitable. This call allows to inquire the network level about a temporary port number assigned when a socket was created as a result of accepting the connection (otherwise, the listening socket port number gets returned as the local port). For connecting sockets, both "trueport" and no "trueport" results are identical (with the exception that "trueport" causes an additional system call, and the result is not stored).
sock | [in] socket handle |
trueport | [in] non-zero causes to refetch / no-cache port from the network layer |
byte_order | [in] byte order for port on return |
Definition at line 7581 of file ncbi_socket.c.
References eNH_HostByteOrder, SOCK_tag::myport, SOCK_tag::path, s_GetLocalPort(), SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::GetLocalPort(), and SOCK_GetLocalPort().
unsigned int SOCK_GetLoopbackAddress | ( | void | ) |
Get loopback IPv4 address.
Definition at line 8821 of file ncbi_socket.c.
References SOCK_LOOPBACK.
Referenced by DBLB_GetServer(), and CSocketAPI::GetLoopbackAddress().
EIO_Status SOCK_GetOSHandle | ( | SOCK | sock, |
void * | handle_buf, | ||
size_t | handle_size | ||
) |
Same as SOCK_GetOSHandleEx(sock, handle_buf, handle_size, eNoOwnership).
Definition at line 7744 of file ncbi_socket.c.
References eNoOwnership, and SOCK_GetOSHandleEx().
Referenced by CRPCClient< TRequest, TReply >::AsyncConnect().
EIO_Status SOCK_GetOSHandleEx | ( | SOCK | sock, |
void * | handle_buf, | ||
size_t | handle_size, | ||
EOwnership | ownership | ||
) |
Get an OS-dependent native socket handle to use by platform-specific API.
FYI: on MS-Windows it will be "SOCKET", on other platforms – "int".
sock | [in] socket handle |
handle_buf | [out] pointer to a memory area to put the OS handle at |
handle_size | [in] the exact(!) size of the expected OS handle |
ownership | eTakeOwnership removes the handle from SOCK; eNoOwnership retains it |
Definition at line 7706 of file ncbi_socket.c.
References assert, CORE_LOGF_X, eIO_InvalidArg, eIO_Success, eLOG_Error, eTakeOwnership, fSOCK_KeepNone, SOCK_tag::keep, MAXIDLEN, s_Close(), s_ID(), s_Initialized, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::GetOSHandle(), and SOCK_GetOSHandle().
void SOCK_GetPeerAddress | ( | SOCK | sock, |
unsigned int * | host, | ||
unsigned short * | port, | ||
ENH_ByteOrder | byte_order | ||
) |
Get host and port of the socket's peer (remote end).
sock | [in] socket handle |
host | [out] the peer's host (can be NULL, then not filled in) |
port | [out] the peer's port (can be NULL, then not filled in) |
byte_order | [in] byte order for either host or port, or both, on return |
Definition at line 7612 of file ncbi_socket.c.
References eNH_HostByteOrder, SOCK_tag::host, and SOCK_tag::port.
Referenced by CSocket::GetPeerAddress(), CDBLB_ServiceMapper::RecordServer(), s_Init(), and SOCK_GetRemotePort().
char* SOCK_GetPeerAddressString | ( | SOCK | sock, |
char * | buf, | ||
size_t | bufsize | ||
) |
Equivalent to SOCK_GetPeerAddressStringEx(.,.,.,eSAF_Full)
Definition at line 7644 of file ncbi_socket.c.
References buf, bufsize, eSAF_Full, and SOCK_GetPeerAddressStringEx().
char* SOCK_GetPeerAddressStringEx | ( | SOCK | sock, |
char * | buf, | ||
size_t | bufsize, | ||
ESOCK_AddressFormat | format | ||
) |
Definition at line 7652 of file ncbi_socket.c.
References buf, bufsize, eSAF_Full, eSAF_IP, eSAF_Port, format, SOCK_tag::host, len, SOCK_tag::path, SOCK_tag::port, SOCK_HostPortToString(), and SOCK_ntoa().
Referenced by CSocket::GetPeerAddress(), SOCK_GetPeerAddressString(), and x_FTPPassive().
TNCBI_BigCount SOCK_GetPosition | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Get current read or write position within a socket.
sock | [in] socket handle |
direction | [in] either eIO_Read or eIO_Write |
Definition at line 8471 of file ncbi_socket.c.
References assert, BUF_Size(), eIO_Read, eIO_Write, eSOCK_Datagram, SOCK_tag::n_read, SOCK_tag::n_written, SOCK_tag::r_buf, SOCK_tag::r_len, SOCK_tag::type, SOCK_tag::w_buf, and SOCK_tag::w_len.
Referenced by CSocket::GetPosition().
unsigned short SOCK_GetRemotePort | ( | SOCK | sock, |
ENH_ByteOrder | byte_order | ||
) |
Get remote port of the socket (the port it is connected to).
The call is provided as a counterpart for SOCK_GetLocalPort(), and is equivalent to calling SOCK_GetPeerAddress(sock, 0, &port, byte_order).
sock | [in] socket handle |
byte_order | [in] byte order for port on return |
Definition at line 7635 of file ncbi_socket.c.
References SOCK_GetPeerAddress().
Referenced by CSocket::GetRemotePort(), and CDBLB_ServiceMapper::RecordServer().
Get the connection's i/o timeout (or NULL, if the timeout is infinite).
sock | [in] socket handle |
event | [in] one of: eIO_[Read/Write/Close] |
Definition at line 7230 of file ncbi_socket.c.
References assert, SOCK_tag::c_to, SOCK_tag::c_tv, SOCK_tag::c_tv_set, CORE_LOGF_X, eIO_Close, eIO_Read, eIO_ReadWrite, eIO_Write, eLOG_Error, MAXIDLEN, SOCK_tag::r_to, SOCK_tag::r_tv, SOCK_tag::r_tv_set, s_ID(), s_tv2to(), SOCK_tag::w_to, SOCK_tag::w_tv, and SOCK_tag::w_tv_set.
Referenced by CSocket::Reset(), s_ReadHeader(), and x_DrainData().
TNCBI_BigCount SOCK_GetTotalCount | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Get the total volume of data transferred by a socket.
sock | [in] socket handle |
direction | [in] either eIO_Read or eIO_Write |
Definition at line 8509 of file ncbi_socket.c.
References assert, eIO_Read, eIO_Write, eSOCK_Datagram, SOCK_tag::n_in, SOCK_tag::n_out, SOCK_tag::n_read, SOCK_tag::n_written, and SOCK_tag::type.
Referenced by CSocket::GetTotalCount().
size_t SOCK_HostPortToString | ( | unsigned int | host, |
unsigned short | port, | ||
char * | buf, | ||
size_t | bufsize | ||
) |
Print numeric string "host:port" into a buffer provided, not to exceed 'bufsize' bytes (including the teminating '\0' character).
Suppress printing the "host" if the 'host' parameter is zero. Suppress printing the ":port" part if 'port' passed as zero, but if both the 'host' and the 'port' parameters are zero, output is the literal ":0".
host | IPv4 in network byte order |
port | in host byte order |
buf | must not be NULL |
bufsize | must be large enough |
Definition at line 8945 of file ncbi_socket.c.
References buf, ncbi::grid::netcache::search::fields::size, and SOCK_HostPortToStringEx().
Referenced by DBLB_GetServer(), DSOCK_Connect(), CSocketAPI::HostPortToString(), LB_Select(), LBSM_SubmitPenaltyOrRerate(), s_CP(), s_CreateListening(), s_DoLog(), s_ID(), LbsmLookup::s_Resolve(), s_Resolve(), s_SendMsg(), SERV_LBDNS_Open(), SERV_Print(), SERV_WriteInfo(), and SOCK_GetPeerAddressStringEx().
See man for the BSDisms, htonl() and htons().
value | The value to convert from host to network byte order. |
Definition at line 8736 of file ncbi_socket.c.
References rapidjson::value.
Referenced by CSocketAPI::HostToNetLong(), NcbiParseIPRange(), s_Init(), s_LoadLocalIPs(), s_ParseHeader(), SERV_ReadInfoEx(), SERV_WriteInfo(), x_FTPPasv(), x_SetHostPort(), and xx_LoadLocalIPs().
unsigned short SOCK_HostToNetShort | ( | unsigned short | value | ) |
See man for the BSDisms, htonl() and htons().
value | The value to convert from host to network byte order. |
Definition at line 8742 of file ncbi_socket.c.
References rapidjson::value.
Referenced by CSocketAPI::HostToNetShort(), x_FTPPort(), and x_StringToIPv6().
Definition at line 8748 of file ncbi_socket.c.
References rapidjson::value.
unsigned short SOCK_htons | ( | unsigned short | value | ) |
Definition at line 8754 of file ncbi_socket.c.
References rapidjson::value.
EIO_Status SOCK_InitializeAPI | ( | void | ) |
Initialize all internal/system data & resources to be used by the SOCK API.
Definition at line 991 of file ncbi_socket.c.
References eIO_Success, eSOCK_ErrInit, info, s_ErrHook, s_ErrorCallback(), and s_Init().
Referenced by CNetScheduleDApp::Init(), CNetStorageDApp::Init(), and CSocketAPI::Initialize().
Check whether a socket is client-side.
sock | [in] socket handle |
Definition at line 8439 of file ncbi_socket.c.
References eSOCK_Client, SOCK_tag::side, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::IsClientSide().
Check whether a socket is a datagram one.
sock | [in] socket handle |
Definition at line 8432 of file ncbi_socket.c.
References eSOCK_Datagram, SOCK_tag::sock, SOCK_INVALID, and SOCK_tag::type.
Referenced by CSocket::IsDatagram().
Equivalent of SOCK_isip(host, 0)
host | [in] '\0'-terminated string to check against being a plain IPv4 address |
Definition at line 8712 of file ncbi_socket.c.
References SOCK_isipEx(), and str().
Referenced by NcbiParseIPRange(), s_ApproveCallback(), s_Connect_(), s_Create(), s_CreateOnTop(), s_gethostbyname_(), s_SendMsg(), SERV_ReadInfoEx(), and x_IsSufficientAddress().
Check whether the given string represents a valid IPv4 address.
host | [in] '\0'-terminated string to check against being a plain IPv4 address |
fullquad | [in] non-zero to only accept "host" if it is a full-quad IPv4 notation |
Definition at line 8680 of file ncbi_socket.c.
References isdigit(), str(), and val.
Referenced by CSocketAPI::isip(), NcbiParseIPRange(), s_gethostbyname_(), SERV_ReadInfoEx(), SOCK_isip(), and x_RedirectOK().
Check whether an address is a loopback one.
Return non-zero (true) if the IPv4 address (in network byte order) given in the agrument, is a loopback one; zero otherwise.
Definition at line 8718 of file ncbi_socket.c.
References IN_LOOPBACKNET, INADDR_LOOPBACK, and ip.
Referenced by NcbiGetHostIfConfEx(), s_gethostbyname(), and x_ChooseSelfIP().
Check whether a socket is using SSL (Secure Socket Layer).
sock | [in] socket handle |
Definition at line 8464 of file ncbi_socket.c.
References SOCK_tag::sock, SOCK_INVALID, and SOCK_tag::sslctx.
Referenced by CSocket::IsSecure(), and s_Connect().
Check whether a socket is server-side.
sock | [in] socket handle |
Definition at line 8446 of file ncbi_socket.c.
References eSOCK_Server, SOCK_tag::side, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::IsServerSide().
Check whether a socket is UNIX type.
sock | [in] socket handle |
Definition at line 8453 of file ncbi_socket.c.
References SOCK_tag::path, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::IsUNIX().
Convert IP address to a string in dotted notation.
addr | [in] must be in the network byte-order |
buf | [out] to be filled by smth. like "123.45.67.89\0" |
bufsize | [in] max # of bytes to put into "buf" (including the terminating '\0') |
Definition at line 8661 of file ncbi_socket.c.
References assert, b, buf, bufsize, and len.
Referenced by CConnTest::CheckFWConnections(), CSocket::Connect(), CDatagramSocket::Connect(), CSocket::CSocket(), dns_a(), DSOCK_RecvMsg(), DSOCK_SendMsg(), DSOCK_WaitMsg(), NcbiDumpIPRange(), CSocketAPI::ntoa(), s_Close(), s_Connect(), s_CreateListening(), s_gethostbyaddr_(), s_gethostbyname(), s_gethostbyname_(), s_GetSysinfo(), s_Init(), s_LookupHost(), s_Open(), s_Read(), s_WaitConnected(), s_Write(), SOCK_GetPeerAddressStringEx(), SOCK_HostPortToStringEx(), SOCK_Shutdown(), SOCK_Wait(), x_ClientAddress(), x_FTPEprt(), x_FTPPassive(), x_IPv6ToString(), and x_SetHostPort().
size_t SOCK_OSHandleSize | ( | void | ) |
Get size of OS-dependent native socket handle.
Definition at line 1069 of file ncbi_socket.c.
Referenced by CSocketAPI::OSHandleSize().
EIO_Status SOCK_Poll | ( | size_t | n, |
SSOCK_Poll | polls[], | ||
const STimeout * | timeout, | ||
size_t * | n_ready | ||
) |
Block until at least one of the sockets enlisted in "polls" array (of size "n") becomes available for requested operation (SSOCK_Poll::event), or until timeout expires (wait indefinitely if timeout is passed as NULL).
Return eIO_Success if at least one socket was found ready; eIO_Timeout if timeout expired; eIO_Unknown if underlying system call(s) failed.
n | [in] # of SSOCK_Poll elems in "polls" |
polls[] | [in|out] array of query/result structures |
timeout | [in] max time to wait (infinite if NULL) |
n_ready | [out] # of ready sockets (may be NULL) |
Definition at line 7083 of file ncbi_socket.c.
References assert, BUF_Size(), eIO_Close, eIO_InvalidArg, eIO_Open, eIO_Read, eIO_ReadWrite, eIO_Success, eIO_Write, SOCK_tag::eof, eSOCK_Socket, eSOCK_Trigger, SSOCK_Poll::event, free(), i, n, SOCK_tag::r_buf, SOCK_tag::r_status, SSOCK_Poll::revent, s_SelectStallsafe(), s_to2tv(), SOCK_tag::sock, SOCK_INVALID, SOCK_tag::type, and SOCK_tag::w_status.
Referenced by SNetServerInPool::GetConnectionFromPool(), and POLLABLE_Poll().
EIO_Status SOCK_Pushback | ( | SOCK | sock, |
const void * | data, | ||
size_t | size | ||
) |
Push the specified data back to the socket's input queue (in the socket's internal read buffer).
These can be any data, not necessarily the data previously read from the socket. The most recently pushed back data are the data that will be read from the socket first (by either SOCK_ReadLine() or SOCK_Read()). The presence of pushed back data makes the socket ready for read immediately (SOCK_Wait(sock, eIO_Read) succeeds without waiting).
sock | [in] socket handle |
data | [in] data to push back to the socket's local buffer |
size | [in] # of bytes (starting at "data") to push back |
Definition at line 7439 of file ncbi_socket.c.
References assert, CORE_LOGF_X, data, eIO_InvalidArg, eIO_Success, eIO_Unknown, eLOG_Error, MAXIDLEN, s_ID(), s_Pushback, ncbi::grid::netcache::search::fields::size, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::Pushback(), s_SOCK_IO(), and x_PushbackBuf().
EIO_Status SOCK_Read | ( | SOCK | sock, |
void * | buf, | ||
size_t | size, | ||
size_t * | n_read, | ||
EIO_ReadMethod | how | ||
) |
Read/peek up to "size" bytes from "sock" to a buffer pointed to by "buf".
In "*n_read", return the number of successfully read bytes. Read method "how" can be either of the following: eIO_ReadPlain – read as many as "size" bytes and return (eIO_Success); if no data are readily available then wait at most read timeout and return (eIO_Timeout) if no data still could be got; eIO_Success if some data were obtained. eIO_ReadPeek – same as "eIO_ReadPlain" but do not extract the data from the socket (so that the next read operation will see the data again), with one important exception noted below. eIO_ReadPersist – read exactly "size" bytes and return eIO_Success; if less data received then return an error condition (including eIO_Timeout).
If there is no data available to read (also, if eIO_ReadPersist and cannot read exactly "size" bytes) and the timeout(see SOCK_SetTimeout()) is expired then return eIO_Timeout.
Both eIO_ReadPlain and eIO_ReadPeek return eIO_Success iff some data have been actually read (within the time allotted by the eIO_Read timeout). Both methods return any other code when no data at all were available. In that respect, eIO_ReadPersist differs from the other two methods as it can return an error condition even if some (but not all) data were actually obtained from the socket.
Hence, as the *rule of thumb*, an application should always check the number of read bytes BEFORE checking the return status, which merely advises as to whether it is okay to read again.
As a special case, "buf" may passed as NULL: eIO_ReadPeek – read up to "size" bytes and store them in internal buffer; eIO_Read[Persist] – discard up to "size" bytes from internal buffer and socket (check "*n_read" to know how many).
sock | [in] socket handle |
buf | [out] data buffer to read to |
size | [in] max # of bytes to read to "buf" |
n_read | [out] # of bytes read (can be NULL) |
how | [in] how to read the data |
Definition at line 7270 of file ncbi_socket.c.
References assert, buf, CORE_LOGF_X, eIO_NotSupported, eIO_ReadPeek, eIO_ReadPersist, eIO_ReadPlain, eIO_Success, eIO_Unknown, eLOG_Error, MAXIDLEN, s_ID(), s_Read(), ncbi::grid::netcache::search::fields::size, SOCK_tag::sock, and SOCK_INVALID.
Referenced by CSocket::Read(), s_Read(), s_ReadData(), s_SOCK_IO(), s_SockRead(), s_VT_Read(), and x_DrainData().
EIO_Status SOCK_ReadLine | ( | SOCK | sock, |
char * | line, | ||
size_t | size, | ||
size_t * | n_read | ||
) |
Read a line from SOCK.
A line is terminated by either '
' (with an optional preceding '\r') or '\0', and is stored in the buffer "line" of "size" characters long. "*n_read" (if "n_read" passed non-NULL) receives the number of characters written into "line", not counting the terminating '\0'. Returned result is '\0'-terminated (and has '\r'(if any)'
' stripped) but only if "size" is big enough to contain the entire line. Otherwise, all "size" bytes are filled, and "*n_read" == "size" upon return, and there is no terminating '\0' in this (and the only!) case, which the caller can easily distinguish. The remainder of the line can be read with successive call(s) to SOCK_ReadLine() until the '\0' terminator is received in the buffer.
sock | [in] socket handle |
line | [out] line buffer to read to, non-NULL |
size | [in] max # of bytes to read to "line", non-0 |
n_read | [out] # of bytes read (optional, can be NULL) |
Definition at line 7329 of file ncbi_socket.c.
References assert, BUF_Size(), CORE_LOGF_X, done, eIO_InvalidArg, eIO_Success, eIO_Unknown, eLOG_Critical, eLOG_Error, SOCK_tag::eof, i, len, MAXIDLEN, SOCK_tag::r_buf, SOCK_tag::r_status, s_ID(), s_Pushback, s_Read(), ncbi::grid::netcache::search::fields::size, SOCK_tag::sock, SOCK_INVALID, and x_size().
Referenced by CSocket::ReadLine(), and x_FTPParseReply().
EIO_Status SOCK_Reconnect | ( | SOCK | sock, |
const char * | host, | ||
unsigned short | port, | ||
const STimeout * | timeout | ||
) |
[CLIENT-side] Close the socket referred to by "sock" and then connect it to another "host:port"; fail if it takes more than "timeout" (close() + connect() [+ select()])
HINT: if "host" is NULL then connect to the same host address as before; if "port" is zero then connect to the same port # as before.
sock | [in] handle of the socket to reconnect |
host | [in] host to connect to (can be NULL) |
port | [in] port to connect to (can be 0) |
timeout | [in] the connect timeout (infinite if NULL) |
Definition at line 6739 of file ncbi_socket.c.
References assert, BUF_Erase(), CORE_LOGF_X, eIO_InvalidArg, eLOG_Error, eSOCK_Client, eSOCK_Datagram, eSOCK_Server, free(), fSOCK_KeepNone, SNcbiSSLctx::host, SOCK_tag::id, MAXIDLEN, SOCK_tag::n_read, SOCK_tag::n_written, SOCK_tag::path, SOCK_tag::r_buf, s_Close(), s_Connect(), s_ID(), SOCK_tag::side, SOCK_tag::sock, SOCK_INVALID, SOCK_tag::sslctx, SOCK_tag::type, and SOCK_tag::w_buf.
Referenced by CSocket::Reconnect().
void SOCK_SetApproveHookAPI | ( | FSOCK_ApproveHook | hook, |
void * | data | ||
) |
The hook is installed when non-NULL, and de-installed otherwise.
optional user data
hook | the hook function |
Definition at line 1623 of file ncbi_socket.c.
References CORE_LOCK_WRITE, CORE_UNLOCK, data, s_ApproveData, and s_ApproveHook.
Control OS-defined send strategy by disabling/enabling the TCP layer to send incomplete network frames (packets).
With the "cork" set on, data gets always buffered until a complete hardware packet is full (or connection is about to close), and only then is sent out to the wire.
sock | [in] socket handle [stream socket only] |
on_off | [in] 1 to set the cork; 0 to remove the cork |
Definition at line 7773 of file ncbi_socket.c.
References assert, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eLOG_Error, eLOG_Warning, eSOCK_Datagram, MAXIDLEN, s_ID(), SOCK_tag::sock, SOCK_ERRNO, SOCK_INVALID, SOCK_STRERROR, SOCK_tag::type, and UTIL_ReleaseBuffer.
Referenced by CORE_SendMailEx(), CSocket::SetCork(), and x_FTPXfer().
Control the data logging for socket "sock" individually.
sock | [in] socket handle |
log | [in] requested data logging To reset to the global default behavior (as set by SOCK_SetDataLoggingAPI), call this function with "log" == eDefault. |
Definition at line 8583 of file ncbi_socket.c.
References log, and SOCK_tag::log.
Referenced by s_FTPCommandEx(), CSocket::SetDataLogging(), x_DrainData(), x_FTPCloseData(), x_FTPPassive(), and x_FTPXfer().
By default data are not logged.
log | To start logging the data, call this func with "log" == eOn. To stop logging the data, call this func with "log" == eOff. To get current log switch, call this func with "log" == eDefault. |
Definition at line 8574 of file ncbi_socket.c.
References eDefault, log, and s_Log.
Referenced by s_FTPCommandEx(), and CSocketAPI::SetDataLogging().
void SOCK_SetErrHookAPI | ( | FSOCK_ErrHook | hook, |
void * | data | ||
) |
Definition at line 384 of file ncbi_socket.c.
References CORE_LOCK_WRITE, CORE_UNLOCK, data, s_ErrData, and s_ErrHook.
Control restartability of I/O interrupted by signals on a per-socket basis.
eDefault causes the use of global API flag.
sock | [in] socket handle |
on_off | [in] per-socket I/O restart behavior on signals |
Definition at line 8541 of file ncbi_socket.c.
References SOCK_tag::i_on_sig.
Referenced by CSocket::SetInterruptOnSignal().
Control restartability of I/O interrupted by signals.
By default I/O is restartable if interrupted. Pass "on_off" as eDefault to get the current setting.
on_off | [in] eOn to cancel I/O on signals; eOff to restart |
Definition at line 8532 of file ncbi_socket.c.
References eDefault, and s_InterruptOnSignal.
Referenced by CSocketAPI::SetInterruptOnSignal().
ESOCK_IOWaitSysAPI SOCK_SetIOWaitSysAPI | ( | ESOCK_IOWaitSysAPI | api | ) |
This is a helper call that can improve I/O performance (ignored for MSVC).
api | [in] Default behavior is to wait for I/O such a way that accomodates the requested sockets accordingly. There is a known limitation of the select() API that requires all sockets to have numeric values of their low-level I/O handles less than (as little as) 1024, but works faster than the poll() API that does not have limits on the number or numeric values of the handles. Either API can be enforced here. |
Definition at line 1086 of file ncbi_socket.c.
References CORE_LOG_X, eLOG_Critical, eSOCK_IOWaitSysAPIPoll, and s_IOWaitSysAPI.
Referenced by CNetScheduleDApp::Run(), CNetStorageDApp::Run(), and CSocketAPI::SetIOWaitSysAPI().
Control the reading-while-writing feature for socket "sock" individually.
To reset to the global default behavior (as set by SOCK_SetReadOnWriteAPI()), call this function with "on_off" == eDefault.
sock | [in] socket handle |
on_off | [in] R-on-W setting for this socket |
Definition at line 7761 of file ncbi_socket.c.
References eDefault, eSOCK_Datagram, SOCK_tag::r_on_w, and SOCK_tag::type.
Referenced by CSocket::SetReadOnWrite().
By default, sockets will not try to read data from inside SOCK_Write().
If you want to automagically upread the data (and cache it in the internal socket buffer) when the write operation is not immediately available, call this func with "on_off" == eOn. Pass "on_off" as eDefault to get current setting.
on_off |
Definition at line 7752 of file ncbi_socket.c.
References eDefault, and s_ReadOnWrite.
Referenced by CSocketAPI::SetReadOnWrite().
Control reuse of socket addresses on per-socket basis Note: only a boolean parameter value is can be used here.
sock | [in] socket handle |
on_off | [in] whether to reuse the address (true, non-zero) or not (false, zero) |
Definition at line 8558 of file ncbi_socket.c.
References CORE_LOGF_ERRNO_EXX, eLOG_Warning, MAXIDLEN, s_ID(), s_SetReuseAddress(), SOCK_tag::sock, SOCK_ERRNO, SOCK_INVALID, SOCK_STRERROR, and UTIL_ReleaseBuffer.
Referenced by CSocket::SetReuseAddress().
Control address reuse for socket addresses taken by the API.
By default address is not marked for reuse in either SOCK or DSOCK, but is always reused for LSOCK (upon socket closure). Pass "on_off" as eDefault to get the current setting.
on_off | [in] whether to turn on (eOn), turn off (eOff) or get current (eDefault) |
Definition at line 8549 of file ncbi_socket.c.
References eDefault, and s_ReuseAddress.
Referenced by CSocketAPI::SetReuseAddress().
This is a helper call that can improve I/O behavior.
timeslice | [in] Break down long waits for I/O into smaller intervals of at most "timeslice" duration each. This can help recover "hanging" sockets from indefinite wait and allow them to report an exceptional I/O condition. |
Definition at line 1075 of file ncbi_socket.c.
References s_SelectTimeout, s_to2tv(), s_tv2to(), and t.
Referenced by CSocketAPI::SetSelectInternalRestartTimeout().
EIO_Status SOCK_SetTimeout | ( | SOCK | sock, |
EIO_Event | event, | ||
const STimeout * | timeout | ||
) |
Specify timeout for the connection I/O (see SOCK_[Read|Write|Close]()).
If "timeout" is NULL then set the timeout to be infinite;
sock | [in] socket handle |
event | [in] one of: eIO_[Read/Write/ReadWrite/Close] |
timeout | [in] new timeout value to set (kDefaultTimeout is not accepted) |
Definition at line 7194 of file ncbi_socket.c.
References assert, SOCK_tag::c_tv, SOCK_tag::c_tv_set, CORE_LOGF_X, eIO_Close, eIO_InvalidArg, eIO_Read, eIO_ReadWrite, eIO_Success, eIO_Write, eLOG_Error, kDefaultTimeout, MAXIDLEN, SOCK_tag::r_tv, SOCK_tag::r_tv_set, s_ID(), s_to2tv(), SOCK_tag::w_tv, and SOCK_tag::w_tv_set.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CORE_SendMailEx(), CSocket::Reset(), s_ConnectAndSend(), s_DropConnection(), s_FTPExecute(), s_PreRead(), s_ReadHeader(), s_VT_Close(), s_VT_Open(), s_VT_Read(), s_VT_Write(), CSocket::SetTimeout(), URL_ConnectEx(), x_Close(), x_DrainData(), x_FTPAbort(), x_FTPCloseCntl(), x_FTPCloseData(), x_FTPCompleteUpload(), x_FTPPollCntl(), and x_FTPSyncCntl().
void SOCK_SetupSSL | ( | FSSLSetup | setup | ) |
Store SSL setup callback until actual initialization.
setup | non-NULL SSL setup routine, or NULL to shut the SSL down |
Definition at line 8998 of file ncbi_socket.c.
References setup(), and SOCK_SetupSSLInternal().
Referenced by s_Fini().
EIO_Status SOCK_SetupSSLEx | ( | FSSLSetup | setup | ) |
Take SSL setup callback, and then init the entire API (SOCK + SSL).
setup | non-NULL SSL setup routine, or NULL to shut the SSL down |
Definition at line 9011 of file ncbi_socket.c.
References setup(), and SOCK_SetupSSLInternalEx().
EIO_Status SOCK_Shutdown | ( | SOCK | sock, |
EIO_Event | how | ||
) |
Shutdown the connection in only one direction (specified by "direction").
Later attempts to I/O (or to wait) in the shutdown direction will do nothing, and immediately return with "eIO_Closed" status. Pending data output can cause data transfer to the remote end (subject for eIO_Close timeout as previously set by SOCK_SetTimeout()). Cannot be applied to datagram sockets (eIO_InvalidArg results).
sock | [in] handle of the socket to shutdown |
how | [in] one of: eIO_Read, eIO_Write, eIO_ReadWrite |
Definition at line 6797 of file ncbi_socket.c.
References assert, CORE_LOGF_X, eIO_Close, eIO_InvalidArg, eIO_ReadWrite, eIO_Success, eLOG_Error, eSOCK_Datagram, eSOCK_ErrIO, SOCK_tag::host, info, MAXIDLEN, SOCK_tag::path, SOCK_tag::port, s_ErrHook, s_ErrorCallback(), s_ID(), s_Shutdown(), SOCK_tag::sock, SOCK_GET_TIMEOUT, SOCK_INVALID, SOCK_ntoa(), and SOCK_tag::type.
Referenced by CSocket::Shutdown().
EIO_Status SOCK_ShutdownAPI | ( | void | ) |
Cleanup; destroy all internal/system data & resources used by the SOCK API.
Definition at line 1019 of file ncbi_socket.c.
References CORE_LOCK_WRITE, CORE_LOG_ERRNO_EXX, CORE_TRACE, CORE_UNLOCK, eIO_NotSupported, eIO_Success, eLOG_Warning, s_Initialized, SOCK_ERRNO, SOCK_STRERROR, UTIL_ReleaseBuffer, and x_ShutdownSSL().
Referenced by CId2FetchApp::Exit(), s_Init(), and CSocketAPI::Shutdown().
const char* SOCK_SSLName | ( | void | ) |
Return an SSL provider name (in a const static storage), with special considerations: return NULL if SSL has not been set up (yet), and return "" if SSL has not been (properly) initialized for use.
Definition at line 9017 of file ncbi_socket.c.
References SOCKSSL_struct::Name, s_SSL, and s_SSLSetup.
Referenced by NcbiCreateTlsCertCredentials().
EIO_Status SOCK_Status | ( | SOCK | sock, |
EIO_Event | direction | ||
) |
Return low-level socket I/O status of *last* socket operation.
This call does not perform any I/O or socket-related system calls.
sock | [in] socket handle |
direction | [in] one of: eIO_Open, eIO_Read, eIO_Write |
Definition at line 7459 of file ncbi_socket.c.
References SOCK_tag::connected, eIO_InvalidArg, eIO_Open, eIO_Read, eIO_Success, eIO_Timeout, eIO_Unknown, eIO_Write, SOCK_tag::eof, eSOCK_Socket, SOCK_tag::pending, SOCK_tag::r_status, SOCK_tag::sock, SOCK_INVALID, SOCK_tag::type, and SOCK_tag::w_status.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::GetStatus(), s_Read(), s_VT_Status(), s_VT_Wait(), x_FTPAbort(), x_FTPParseReply(), and x_RetryStatus().
Read (skipping leading blanks) "[host][:port]" from a string stopping at either EOL or a blank character.
str | must not be NULL |
host | may be NULL for no assignment |
port | may be NULL for no assignment |
Definition at line 8901 of file ncbi_socket.c.
References SOCK_StringToHostPortEx(), and str().
Referenced by CDatagramSocket::Connect(), CSocket::Connect(), CSocket::CSocket(), DBLB_GetServer(), and CSocketAPI::StringToHostPort().
EIO_Status SOCK_Wait | ( | SOCK | sock, |
EIO_Event | event, | ||
const STimeout * | timeout | ||
) |
Block on the socket until either the specified "event" is available or "timeout" expires (if "timeout" is NULL then assume it infinite).
eIO_Open (as "event") can be used to check whether the socket has been connected. When eIO_Read is requested as an "event" for a datagram socket, then eIO_Closed results if the internally latched message has been entirely read out. Either of eIO_Open, eIO_Write and eIO_ReadWrite always succeeds immediately for a datagram socket.
sock | [in] socket handle |
event | [in] one of: eIO_Open, eIO_Read, eIO_Write, eIO_ReadWrite |
timeout | [in] maximal time to wait for the event to occur (not kDefaultTimeout!) |
Definition at line 6953 of file ncbi_socket.c.
References assert, BUF_Size(), SOCK_tag::connected, CORE_LOGF_X, eIO_InvalidArg, eIO_Open, eIO_Read, eIO_ReadWrite, eIO_Success, eIO_Timeout, eIO_Unknown, eIO_Write, eLOG_Error, eLOG_Warning, SOCK_tag::eof, eSOCK_Datagram, eSOCK_ErrIO, eSOCK_Socket, SOCK_tag::host, info, kDefaultTimeout, MAXIDLEN, SOCK_tag::path, SOCK_tag::pending, SOCK_tag::port, SOCK_tag::r_buf, SOCK_tag::r_status, s_ErrHook, s_ErrorCallback(), s_ID(), s_to2tv(), s_Wait(), s_WaitConnected(), SOCK_tag::sock, SOCK_INVALID, SOCK_ntoa(), SOCK_tag::type, and SOCK_tag::w_status.
Referenced by CORE_SendMailEx(), s_VT_Wait(), CSocket::Wait(), and x_FTPPollCntl().
EIO_Status SOCK_Write | ( | SOCK | sock, |
const void * | data, | ||
size_t | size, | ||
size_t * | n_written, | ||
EIO_WriteMethod | how | ||
) |
Write "size" bytes of "data" to "sock".
sock | [in] socket handle |
data | [in] data to write to the socket |
size | [in] # of bytes (starting at "data") to write |
n_written | [out] # of written bytes (can be NULL) |
how | [in] either eIO_WritePlain or eIO_WritePersist |
Definition at line 7486 of file ncbi_socket.c.
References assert, CORE_LOGF_X, data, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_WriteOutOfBand, eIO_WritePersist, eIO_WritePlain, eLOG_Error, eSOCK_Datagram, MAXIDLEN, s_ID(), s_Write(), ncbi::grid::netcache::search::fields::size, SOCK_tag::sock, SOCK_INVALID, and SOCK_tag::type.
Referenced by s_ConnectAndSend(), s_FTPCommandEx(), s_SockWrite(), s_VT_Write(), CSocket::Write(), x_FTPTelnetSynch(), and x_WriteBuf().
Definition at line 767 of file ncbi_socket.hpp.
|
static |
Return position past the end of the parsed portion, NPOS on error.
Definition at line 694 of file ncbi_socket_cxx.cpp.
References NPOS, SOCK_StringToHostPort(), and str().
Referenced by NcbiOpenURL(), and CConnTest::x_GetFirewallConfiguration().
EIO_Status TRIGGER_Close | ( | TRIGGER | trigger | ) |
Close an event trigger.
trigger | [in] a handle returned by TRIGGER_Create() |
Definition at line 6341 of file ncbi_socket.c.
References close(), CORE_LOGF_X, eDefault, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eLOG_Note, eOn, TRIGGER_tag::fd, free(), TRIGGER_tag::id, TRIGGER_tag::log, TRIGGER_tag::out, and s_Log.
Referenced by CTrigger::~CTrigger().
EIO_Status TRIGGER_Create | ( | TRIGGER * | trigger, |
ESwitch | log | ||
) |
Create an event trigger.
trigger | [in|out] a pointer to a location where to store handle of the new trigger |
Definition at line 6180 of file ncbi_socket.c.
References assert, calloc(), close(), CORE_LOGF_ERRNO_EXX, CORE_LOGF_ERRNO_X, CORE_LOGF_X, eDefault, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_Unknown, eLOG_Error, eLOG_Note, eLOG_Warning, eOn, eSOCK_Trigger, FD_SETSIZE, HANDLE, log, s_InitAPI(), s_Log, s_SetCloexec(), s_SetNonblock(), s_WinStrerror(), UTIL_ReleaseBufferOnHeap(), and x_ID_Counter().
Referenced by CTrigger::CTrigger().
EIO_Status TRIGGER_IsSet | ( | TRIGGER | trigger | ) |
Check whether the trigger has been set.
Should not be used from multiple threads concurrently at a time, including along with TRIGGER_Reset().
trigger | [in] a handle returned by TRIGGER_Create() |
Definition at line 6452 of file ncbi_socket.c.
References eIO_InvalidArg, eIO_Success, eIO_Timeout, TRIGGER_tag::isset, TRIGGER_tag::ptr, and x_TriggerRead().
Referenced by CTrigger::IsSet().
EIO_Status TRIGGER_Reset | ( | TRIGGER | trigger | ) |
Reset the trigger.
Should not be used from multiple threads concurrently, including along with TRIGGER_IsSet().
trigger | [in] a handle returned by TRIGGER_Create() |
Definition at line 6477 of file ncbi_socket.c.
References eIO_InvalidArg, eIO_Success, eIO_Timeout, eIO_Unknown, TRIGGER_tag::fd, TRIGGER_tag::isset, TRIGGER_tag::ptr, and x_TriggerRead().
Referenced by CTrigger::Reset().
EIO_Status TRIGGER_Set | ( | TRIGGER | trigger | ) |
Set an event trigger.
Can be used from many threads concurrently.
trigger | [in] a handle returned by TRIGGER_Create() |
Definition at line 6377 of file ncbi_socket.c.
References CORE_Once, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_Unknown, TRIGGER_tag::fd, TRIGGER_tag::isset, TRIGGER_tag::out, and TRIGGER_tag::ptr.
Referenced by CTrigger::Set().
|
inline |
timeout |
Definition at line 1092 of file ncbi_socket.hpp.
References DSOCK_WaitMsg(), and CSocket::m_Socket.
Referenced by SNetScheduleNotificationThread::Main(), and CNetScheduleNotificationHandler::WaitForNotification().
|
inline |
Wait for I/O availability in the socket.
event | either of eIO_Read, eIO_Write or eIO_ReadWrite |
timeout | maximal time to wait for I/O to become ready |
Definition at line 902 of file ncbi_socket.hpp.
References CSocket::m_Socket, and SOCK_Wait().
EIO_Status CSocket::Write | ( | const void * | buf, |
size_t | size, | ||
size_t * | n_written = 0 , |
||
EIO_WriteMethod | how = eIO_WritePersist |
||
) |
Write to socket.
buf | |
size | |
n_written | |
how |
Definition at line 376 of file ncbi_socket_cxx.cpp.
References buf, CSocket::m_Socket, ncbi::grid::netcache::search::fields::size, and SOCK_Write().
Referenced by CBDBEnvKeeperConnectionHandler::OnMessage(), s_HandleError(), s_WriteToSocket(), CServer_Monitor::SendMessage(), CSocketReaderWriter::Write(), SNetServerConnectionImpl::WriteLine(), SGridWorkerNodeImpl::x_AreMastersBusy(), CWNCTConnectionHandler::x_ProcessRequest(), CNetStorageHandler::x_SendOutputBuffer(), CNetStorageHandler::x_SendOverUTTP(), and CNetScheduleHandler::x_WriteMessage().
|
virtual |
Call Close(), then self-destruct.
Definition at line 520 of file ncbi_socket_cxx.cpp.
References CListeningSocket::Close().
|
inlinevirtual |
Definition at line 67 of file ncbi_socket.hpp.
|
virtual |
Call Close(), then self-destruct.
Definition at line 137 of file ncbi_socket_cxx.cpp.
References eNoOwnership, CSocket::m_IsOwned, CSocket::m_Socket, and SOCK_Close().
|
virtual |
Definition at line 50 of file ncbi_socket_cxx.cpp.
References CTrigger::m_Trigger, and TRIGGER_Close().
unsigned int SSOCK_ApproveInfo::addr |
IPv4 (or -1 if unknown / broadcast), never 0.
Definition at line 345 of file ncbi_socket.h.
|
protected |
eIO_Close
Definition at line 506 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::GetTimeout(), CSocket::Reset(), and CSocket::SetTimeout().
|
protected |
storage for c_timeout
Definition at line 514 of file ncbi_socket.hpp.
Referenced by CSocket::Reset(), and CSocket::SetTimeout().
EIO_Event SSOCK_Poll::event |
[in] SOCK to poll (NULL if not to poll)
Definition at line 968 of file ncbi_socket.h.
Referenced by s_Select(), and SOCK_Poll().
EIO_Event SSOCK_ErrInfo::event |
Meaningful only for the eSOCK_ErrIO type.
Definition at line 1955 of file ncbi_socket.h.
EIO_Event SPOLLABLE_Poll::event |
Definition at line 1980 of file ncbi_socket.h.
Referenced by CSocketAPI::Poll().
const char* SSOCK_ApproveInfo::host |
Textual hostname if provided for outgoing.
Definition at line 344 of file ncbi_socket.h.
const char* SSOCK_ErrInfo::host |
Host name/IP (or path for non-IP SOCK)
Definition at line 1953 of file ncbi_socket.h.
EIO_Event CSocketAPI::SPoll::m_Event |
[in] event inqury (or eIO_Open for none)
Definition at line 764 of file ncbi_socket.hpp.
|
protected |
Timeouts.
Definition at line 495 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::Reset(), CSocket::SetOwnership(), and CSocket::~CSocket().
|
protected |
Definition at line 711 of file ncbi_socket.hpp.
Referenced by CListeningSocket::Close(), and CListeningSocket::SetOwnership().
CPollable* CSocketAPI::SPoll::m_Pollable |
[in] object pointer (or NULL not to poll)
Definition at line 763 of file ncbi_socket.hpp.
EIO_Event CSocketAPI::SPoll::m_REvent |
[out] event ready (eIO_Open if not ready)
Definition at line 765 of file ncbi_socket.hpp.
|
protected |
Definition at line 494 of file ncbi_socket.hpp.
Referenced by CSocket::Abort(), CDatagramSocket::Bind(), CDatagramSocket::CDatagramSocket(), CDatagramSocket::Clear(), CSocket::Close(), CUNIXSocket::Connect(), CDatagramSocket::Connect(), CSocket::Connect(), CSocket::CSocket(), CUNIXSocket::CUNIXSocket(), CSocket::DisableOSSendDelay(), CSocket::GetCount(), CSocket::GetLocalPort(), CDatagramSocket::GetMessageCount(), CSocket::GetOSHandle(), CSocket::GetPeerAddress(), CSocket::GetPOLLABLE(), CSocket::GetPosition(), CSocket::GetRemotePort(), CSocket::GetSOCK(), CSocket::GetStatus(), CSocket::GetTotalCount(), CSocket::IsClientSide(), CSocket::IsDatagram(), CSocket::IsEmpty(), CSocket::IsSecure(), CSocket::IsServerSide(), CSocket::IsUNIX(), CSocket::Pushback(), CSocket::Read(), CSocket::ReadLine(), CSocket::Reconnect(), CDatagramSocket::Recv(), CSocket::Reset(), CDatagramSocket::Send(), CDatagramSocket::SetBroadcast(), CSocket::SetCork(), CSocket::SetDataLogging(), CSocket::SetInterruptOnSignal(), CSocket::SetReadOnWrite(), CSocket::SetReuseAddress(), CSocket::SetTimeout(), CSocket::Shutdown(), CDatagramSocket::Wait(), CSocket::Wait(), CSocket::Write(), and CSocket::~CSocket().
|
protected |
Definition at line 710 of file ncbi_socket.hpp.
Referenced by CListeningSocket::Accept(), CListeningSocket::CListeningSocket(), CListeningSocket::Close(), CUNIXListeningSocket::CUNIXListeningSocket(), CListeningSocket::GetLSOCK(), CListeningSocket::GetOSHandle(), CListeningSocket::GetPOLLABLE(), CListeningSocket::GetPort(), CListeningSocket::GetStatus(), CListeningSocket::IsEmpty(), CUNIXListeningSocket::Listen(), and CListeningSocket::Listen().
|
protected |
Definition at line 110 of file ncbi_socket.hpp.
Referenced by CTrigger::CTrigger(), CTrigger::GetOSHandle(), CTrigger::GetPOLLABLE(), CTrigger::GetStatus(), CTrigger::GetTRIGGER(), CTrigger::IsSet(), CTrigger::Reset(), CTrigger::Set(), and CTrigger::~CTrigger().
|
protected |
eIO_Open
Definition at line 500 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::CSocket(), CUNIXSocket::CUNIXSocket(), CSocket::GetTimeout(), CSocket::Reconnect(), and CSocket::SetTimeout().
|
protected |
storage for o_timeout
Definition at line 508 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::CSocket(), CUNIXSocket::CUNIXSocket(), CSocket::Reconnect(), and CSocket::SetTimeout().
POLLABLE SPOLLABLE_Poll::poll |
Definition at line 1979 of file ncbi_socket.h.
Referenced by CSocketAPI::Poll().
unsigned short SSOCK_ApproveInfo::port |
Port number, host byte order, never 0.
Definition at line 346 of file ncbi_socket.h.
unsigned short SSOCK_ErrInfo::port |
Port (host byte order), 0 for non-IP SOCK.
Definition at line 1954 of file ncbi_socket.h.
|
protected |
eIO_Read
Definition at line 502 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::GetTimeout(), CSocket::Reset(), and CSocket::SetTimeout().
EIO_Event SSOCK_Poll::revent |
[in] one of: eIO_Open/Read/Write/ReadWrite
Definition at line 969 of file ncbi_socket.h.
Referenced by SNetServerInPool::GetConnectionFromPool(), s_Select(), s_SelectStallsafe(), and SOCK_Poll().
EIO_Event SPOLLABLE_Poll::revent |
Definition at line 1981 of file ncbi_socket.h.
Referenced by CSocketAPI::Poll().
|
protected |
storage for r_timeout
Definition at line 510 of file ncbi_socket.hpp.
Referenced by CSocket::Reset(), and CSocket::SetTimeout().
ESOCK_Side SSOCK_ApproveInfo::side |
eSOCK_Client (out) / eSOCK_Server (in)
Definition at line 347 of file ncbi_socket.h.
SOCK SSOCK_Poll::sock |
Definition at line 967 of file ncbi_socket.h.
Referenced by s_Select(), and s_SelectStallsafe().
SOCK SSOCK_ErrInfo::sock |
Non-NULL when SOCK-related.
Definition at line 1952 of file ncbi_socket.h.
EIO_Status SSOCK_ErrInfo::status |
Status code about to be returned (if known)
Definition at line 1956 of file ncbi_socket.h.
ESOCK_Type SSOCK_ApproveInfo::type |
eSOCK_Socket (conn) / eSOCK_Datagram (packet)
Definition at line 348 of file ncbi_socket.h.
ESOCK_ErrType SSOCK_ErrInfo::type |
See ESOCK_ErrType.
Definition at line 1951 of file ncbi_socket.h.
|
protected |
eIO_Write
Definition at line 504 of file ncbi_socket.hpp.
Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::GetTimeout(), CSocket::Reset(), and CSocket::SetTimeout().
|
protected |
storage for w_timeout
Definition at line 512 of file ncbi_socket.hpp.
Referenced by CSocket::Reset(), and CSocket::SetTimeout().