Collaboration diagram for Socket Services:
Classes | |
struct | SSOCK_Poll |
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... | |
class | CUNIXSocket |
class | CUNIXListeningSocket |
Defines | |
#define | SOCK_NetToHostLong SOCK_HostToNetLong |
#define | SOCK_NetToHostShort SOCK_HostToNetShort |
#define | NCBI_SOCK_DEPRECATED |
#define | SOCK_ntohl SOCK_htonl |
#define | SOCK_ntohs SOCK_htons |
Typedefs | |
typedef LSOCK_tag * | LSOCK |
typedef SOCK_tag * | SOCK |
typedef TRIGGER_tag * | TRIGGER |
typedef unsigned int | TSOCK_Flags |
typedef SPOLLABLE_tag * | POLLABLE |
typedef const struct SOCKSSL_struct * | SOCKSSL |
typedef SOCKSSL(* | FSSLSetup )(void) |
Enumerations | |
enum | ENH_ByteOrder { eNH_HostByteOrder, eNH_NetworkByteOrder } |
Network and host byte order enumeration type. More... | |
enum | ESOCK_Flags { fSOCK_LogOff = eOff, fSOCK_LogOn = eOn, fSOCK_LogDefault = eDefault, fSOCK_BindAny = 0, fSOCK_BindLocal = 0x10, fSOCK_KeepOnExec = 0x20, fSOCK_CloseOnExec = 0, fSOCK_Secure = 0x40, fSOCK_KeepOnClose = 0x80, fSOCK_CloseOnClose = 0, fSOCK_ReadOnWrite = 0x100, fSOCK_InterruptOnSignal = 0x200 } |
enum | ELSCE_Flags { fLSCE_LogOff = fSOCK_LogOff, fLSCE_LogOn = fSOCK_LogOn, fLSCE_LogDefault = fSOCK_LogDefault, fLSCE_BindAny = fSOCK_BindAny, fLSCE_BindLocal = fSOCK_BindLocal, fLSCE_CloseOnExec = fSOCK_CloseOnExec } |
enum | ESCOT_OnClose { eSCOT_KeepOnClose = fSOCK_KeepOnClose, eSCOT_CloseOnClose = fSOCK_CloseOnClose } |
SOCK_Close behavior for SOCKs created on top of OS handles. More... | |
enum | ECopyTimeout { eCopyTimeoutsFromSOCK, eCopyTimeoutsToSOCK } |
Functions | |
SOCKSSL | NcbiSetupGnuTls (void) |
ESwitch | SOCK_SetDataLoggingAPI (ESwitch log) |
By default ("log" == eDefault, which is eOff), data are not logged. | |
ESwitch | SOCK_SetDataLogging (SOCK sock, ESwitch log) |
Control the data logging for socket "sock" individually. | |
ESwitch | SOCK_SetInterruptOnSignalAPI (ESwitch on_off) |
Control restartability of I/O interrupted by signals. | |
ESwitch | SOCK_SetInterruptOnSignal (SOCK sock, ESwitch on_off) |
Control restartability of I/O interrupted by signals on a per-socket basis. | |
ESwitch | SOCK_SetReuseAddressAPI (ESwitch on_off) |
Control address reuse for socket addresses taken by the API. | |
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. | |
const STimeout * | SOCK_SetSelectInternalRestartTimeout (const STimeout *timeout) |
This is a helper call that can improve I/O behavior. | |
void | SOCK_AllowSigPipeAPI (void) |
By default (on UNIX platforms) the SOCK API functions automagically call "signal(SIGPIPE, SIG_IGN)" on initialization. | |
EIO_Status | SOCK_InitializeAPI (void) |
Initialize all internal/system data & resources to be used by the SOCK API. | |
EIO_Status | SOCK_ShutdownAPI (void) |
Cleanup; destroy all internal/system data & resources used by the SOCK API. | |
EIO_Status | TRIGGER_Create (TRIGGER *trigger, ESwitch log) |
Create an event trigger. | |
EIO_Status | TRIGGER_Close (TRIGGER trigger) |
Close an event trigger. | |
EIO_Status | TRIGGER_Set (TRIGGER trigger) |
Set an event trigger. | |
EIO_Status | TRIGGER_IsSet (TRIGGER trigger) |
Check whether the trigger has been set. | |
EIO_Status | TRIGGER_Reset (TRIGGER trigger) |
Reset trigger. | |
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()) | |
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. | |
EIO_Status | LSOCK_Accept (LSOCK lsock, const STimeout *timeout, SOCK *sock) |
[SERVER-side] Accept connection from a client. | |
EIO_Status | LSOCK_Close (LSOCK lsock) |
[SERVER-side] Close the listening socket, destroy relevant internal data. | |
EIO_Status | LSOCK_GetOSHandle (LSOCK lsock, void *handle_buf, size_t) |
Get an OS-dependent native socket handle to use by platform-specific API. | |
EIO_Status | SOCK_CreateEx (const char *host, unsigned short port, const STimeout *timeout, SOCK *sock, const void *init_data, size_t init_size, TSOCK_Flags flags) |
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()]) | |
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). | |
EIO_Status | SOCK_CreateOnTopEx (const void *handle, size_t handle_size, SOCK *sock, const void *init_data, size_t init_size, TSOCK_Flags flags) |
[SERVER-side] Create a socket on top of OS-dependent "handle" (file descriptor on Unix, SOCKET on MS-Windows). | |
EIO_Status | SOCK_CreateOnTop (const void *handle, size_t handle_size, SOCK *sock) |
[SERVER-side] Create a socket on top of OS-dependent "handle". | |
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()]) | |
EIO_Status | SOCK_Shutdown (SOCK sock, EIO_Event how) |
Shutdown the connection in only one direction (specified by "direction"). | |
EIO_Status | SOCK_Close (SOCK sock) |
Close the connection, destroy relevant internal data. | |
EIO_Status | SOCK_CloseEx (SOCK sock, int destroy) |
Close the connection, and conditionally destroy relevant internal data. | |
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_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 (event), or until timeout expires (wait indefinitely if timeout is passed NULL). | |
EIO_Status | POLLABLE_Poll (size_t n, SPOLLABLE_Poll polls[], const STimeout *timeout, size_t *n_ready) |
POLLABLE | POLLABLE_FromSOCK (SOCK) |
POLLABLE | POLLABLE_FromLSOCK (LSOCK) |
POLLABLE | POLLABLE_FromTRIGGER (TRIGGER) |
SOCK | POLLABLE_ToSOCK (POLLABLE) |
LSOCK | POLLABLE_ToLSOCK (POLLABLE) |
TRIGGER | POLLABLE_ToTRIGGER (POLLABLE) |
EIO_Status | SOCK_SetTimeout (SOCK sock, EIO_Event event, const STimeout *timeout) |
Specify timeout for the connection i/o (see SOCK_[Read|Write|Close] funcs). | |
const STimeout * | SOCK_GetTimeout (SOCK sock, EIO_Event event) |
Get the connection's i/o timeout (or NULL, if the timeout is infinite). | |
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 the mem.buffer pointed by "buf". | |
EIO_Status | SOCK_ReadLine (SOCK sock, char *buf, size_t size, size_t *n_read) |
Read a line from SOCK. | |
EIO_Status | SOCK_PushBack (SOCK sock, const void *buf, size_t size) |
Push the specified data back to the socket input queue (in the socket's internal read buffer). | |
EIO_Status | SOCK_Status (SOCK sock, EIO_Event direction) |
Return low-level socket I/O status of *last* socket operation. | |
EIO_Status | SOCK_Write (SOCK sock, const void *buf, size_t size, size_t *n_written, EIO_WriteMethod how) |
Write "size" bytes from buffer "buf" to "sock". | |
EIO_Status | SOCK_Abort (SOCK sock) |
If there is outstanding connection or output data pending, cancel it. | |
unsigned short | SOCK_GetLocalPort (SOCK sock, ENH_ByteOrder byte_order) |
Get local port of the socket. | |
void | SOCK_GetPeerAddress (SOCK sock, unsigned int *host, unsigned short *port, ENH_ByteOrder byte_order) |
Get host and port of the socket's peer. | |
char * | SOCK_GetPeerAddressString (SOCK sock, char *buf, size_t buflen) |
Get textual representation of the socket's peer. | |
EIO_Status | SOCK_GetOSHandle (SOCK sock, void *handle_buf, size_t handle_size) |
Get an OS-dependent native socket handle to use by platform-specific API. | |
ESwitch | SOCK_SetReadOnWriteAPI (ESwitch on_off) |
By default ("on_off" == eDefault,eOff), sockets will not try to read data from inside SOCK_Write(). | |
ESwitch | SOCK_SetReadOnWrite (SOCK sock, ESwitch on_off) |
Control the reading-while-writing feature for socket "sock" individually. | |
void | SOCK_DisableOSSendDelay (SOCK sock, int on_off) |
Control OS-defined send strategy by disabling/enabling TCP Nagle algorithm that packs multiple requests into a single frame and thus transferring data in fewer transactions, miminizing the network traffic and bursting the throughput. | |
EIO_Status | DSOCK_Create (SOCK *sock) |
EIO_Status | DSOCK_CreateEx (SOCK *sock, TSOCK_Flags flags) |
EIO_Status | DSOCK_Bind (SOCK sock, unsigned short port) |
EIO_Status | DSOCK_Connect (SOCK sock, const char *host, unsigned short port) |
EIO_Status | DSOCK_WaitMsg (SOCK sock, const STimeout *timeout) |
EIO_Status | DSOCK_SendMsg (SOCK sock, const char *host, unsigned short port, const void *data, size_t datalen) |
EIO_Status | DSOCK_RecvMsg (SOCK sock, void *buf, size_t buflen, size_t maxmsglen, size_t *msglen, unsigned int *sender_addr, unsigned short *sender_port) |
EIO_Status | DSOCK_WipeMsg (SOCK sock, EIO_Event direction) |
EIO_Status | DSOCK_SetBroadcast (SOCK sock, int broadcast) |
int | SOCK_IsDatagram (SOCK sock) |
bool | |
int | SOCK_IsClientSide (SOCK sock) |
bool | |
int | SOCK_IsServerSide (SOCK sock) |
bool | |
int | SOCK_IsUNIX (SOCK sock) |
bool | |
int | SOCK_IsSecure (SOCK sock) |
bool | |
int | SOCK_gethostname (char *name, size_t namelen) |
int | SOCK_ntoa (unsigned int addr, char *buf, size_t buflen) |
int | SOCK_isipEx (const char *host, int fullquad) |
int | SOCK_isip (const char *host) |
Equivalent of SOCK_isip(host, 0). | |
unsigned int | SOCK_HostToNetLong (unsigned int value) |
See man for the BSDisms, htonl() and htons(). | |
unsigned short | SOCK_HostToNetShort (unsigned short value) |
unsigned int | SOCK_htonl (unsigned int) |
unsigned short | SOCK_htons (unsigned short) |
unsigned int | SOCK_gethostbyname (const char *hostname) |
char * | SOCK_gethostbyaddr (unsigned int addr, char *name, size_t namelen) |
Take INET host address (in network byte order) and fill out the the provided buffer with the name, which the address corresponds to (in case of multiple names the primary name is used). | |
unsigned int | SOCK_GetLoopbackAddress (void) |
unsigned int | SOCK_GetLocalHostAddress (ESwitch reget) |
Get (and cache for faster follow-up retrievals) the address of local host. | |
const char * | SOCK_StringToHostPort (const char *str, unsigned int *host, unsigned short *port) |
Read (skipping leading blanks) "[host][:port]" from a string. | |
size_t | SOCK_HostPortToString (unsigned int host, unsigned short port, char *buf, size_t buflen) |
Print host:port into provided buffer string, not to exceed 'buflen' size. | |
void | SOCK_SetupSSL (FSSLSetup setup) |
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 *init_data, size_t init_size, TSOCK_Flags flags) |
|
Definition at line 1567 of file ncbi_socket.h. |
|
Definition at line 1552 of file ncbi_socket.h. Referenced by CSocketAPI::NetToHostLong(). |
|
Definition at line 1562 of file ncbi_socket.h. Referenced by CSocketAPI::NetToHostShort(). |
|
Definition at line 1573 of file ncbi_socket.h. |
|
Definition at line 1576 of file ncbi_socket.h. |
|
Definition at line 1688 of file ncbi_socket.h. |
|
Definition at line 170 of file ncbi_socket.h. |
|
Definition at line 863 of file ncbi_socket.h. |
|
Definition at line 173 of file ncbi_socket.h. |
|
Definition at line 1685 of file ncbi_socket.h. |
|
Definition at line 176 of file ncbi_socket.h. |
|
Definition at line 462 of file ncbi_socket.h. |
|
Definition at line 55 of file ncbi_socket.hpp. |
|
Definition at line 469 of file ncbi_socket.h. |
|
Network and host byte order enumeration type.
Definition at line 160 of file ncbi_socket.h. |
|
SOCK_Close behavior for SOCKs created on top of OS handles.
Definition at line 634 of file ncbi_socket.h. |
|
Definition at line 448 of file ncbi_socket.h. |
|
Definition at line 5051 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDatagram, eDefault, eIO_Closed, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Trace, eOn, SOCK_tag::log, SOCK_tag::myport, s_DoLog(), s_ID(), s_Log, SOCK_tag::sock, SOCK_EADDRINUSE, and SOCK_tag::type. Referenced by CDatagramSocket::Bind(). |
|
Definition at line 5096 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDatagram, eDefault, eIO_Closed, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, eOn, SOCK_tag::host, SOCK_tag::id, SOCK_tag::log, SOCK_tag::port, s_DoLog(), s_ID(), s_Log, s_WipeRBuf(), s_WipeWBuf(), SOCK_tag::sock, SOCK_gethostbyname(), SOCK_HostPortToString(), and SOCK_tag::type. Referenced by CDatagramSocket::Connect(). |
|
Definition at line 4930 of file ncbi_socket.c. References DSOCK_CreateEx(), and fSOCK_LogDefault. |
|
Definition at line 4936 of file ncbi_socket.c. References BUF_SetChunkSize(), CORE_LOGF_ERRNO_EXX, eDatagram, eDefault, eIO_NotSupported, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Warning, eOn, eSOCK_Client, FALSE, fSOCK_InterruptOnSignal, fSOCK_KeepOnClose, fSOCK_KeepOnExec, fSOCK_Secure, s_DoLog(), s_ID(), s_ID_Counter, s_InitAPI(), s_Log, s_SetNonblock(), SOCK_BUF_CHUNK_SIZE, and TRUE. Referenced by CDatagramSocket::CDatagramSocket(), and DSOCK_Create(). |
|
Definition at line 5322 of file ncbi_socket.c. References BUF_Write(), CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDatagram, eDefault, eIO_Close, eIO_Closed, eIO_Interrupt, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Trace, eOn, SSOCK_Poll::event, SOCK_tag::i_on_sig, SOCK_tag::log, SOCK_tag::n_in, SOCK_tag::n_read, SOCK_tag::r_buf, SOCK_tag::r_status, SOCK_tag::r_timeout, SSOCK_Poll::revent, s_DoLog(), s_ID(), s_InterruptOnSignal, s_Log, s_Select(), s_WipeRBuf(), SOCK_tag::sock, SSOCK_Poll::sock, SOCK_EAGAIN, SOCK_EINTR, SOCK_EWOULDBLOCK, and SOCK_tag::type. Referenced by CDatagramSocket::Recv(). |
|
Definition at line 5180 of file ncbi_socket.c. References BUF_Peek(), BUF_Size(), CORE_LOGF_X, eDatagram, eDefault, eIO_Closed, eIO_InvalidArg, eIO_Unknown, eIO_Write, SOCK_tag::eof, eOn, SOCK_tag::host, SOCK_tag::log, SOCK_tag::port, s_DoLog(), s_ID(), s_Log, s_Write(), SOCK_tag::sock, SOCK_gethostbyname(), SOCK_tag::type, verify, and SOCK_tag::w_buf. Referenced by CDatagramSocket::Send(). |
|
Definition at line 5523 of file ncbi_socket.c. References BOOL, CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDatagram, eIO_Closed, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_Unknown, s_ID(), SOCK_tag::sock, and SOCK_tag::type. Referenced by CDatagramSocket::SetBroadcast(). |
|
Definition at line 5453 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_Close, eIO_Closed, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Unknown, SSOCK_Poll::event, SSOCK_Poll::revent, s_ID(), s_Select(), s_to2tv(), SOCK_tag::sock, SSOCK_Poll::sock, and SOCK_tag::type. Referenced by CDatagramSocket::Wait(). |
|
Definition at line 5485 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_Closed, eIO_InvalidArg, eIO_Write, SOCK_tag::r_status, s_ID(), s_WipeRBuf(), s_WipeWBuf(), SOCK_tag::sock, SOCK_tag::type, and SOCK_tag::w_status. Referenced by CDatagramSocket::Clear(). |
|
[SERVER-side] Accept connection from a client.
Definition at line 3753 of file ncbi_socket.c. References fSOCK_LogDefault, and s_Accept(). Referenced by CListeningSocket::Accept(). |
|
[SERVER-side] Close the listening socket, destroy relevant internal data.
Definition at line 3770 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, CORE_LOGF_X, eDefault, eIO_Success, eIO_Unknown, eLOG_Trace, eOn, LSOCK_tag::id, LSOCK_tag::keep, LSOCK_tag::log, LSOCK_tag::n_accept, LSOCK_tag::port, s_Initialized, s_Log, s_SetNonblock(), LSOCK_tag::sock, SOCK_EINTR, and SOCK_HostPortToString(). Referenced by CListeningSocket::Close(). |
|
[SERVER-side] Create and initialize the server-side(listening) socket Same as LSOCK_CreateEx called with the last argument provided as fSOCK_LogDefault.
Definition at line 3497 of file ncbi_socket.c. References fSOCK_LogDefault, and s_CreateListening(). |
|
[SERVER-side] Create and initialize the server-side(listening) socket (socket() + bind() + listen())
Definition at line 3505 of file ncbi_socket.c. References s_CreateListening(). Referenced by CListeningSocket::CListeningSocket(), and CListeningSocket::Listen(). |
|
Definition at line 3514 of file ncbi_socket.c. References s_CreateListening(). Referenced by CUNIXListeningSocket::CUNIXListeningSocket(), and CUNIXListeningSocket::Listen(). |
|
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".
Definition at line 3855 of file ncbi_socket.c. References CORE_LOGF_X, eIO_Closed, eIO_InvalidArg, eIO_Success, LSOCK_tag::id, and LSOCK_tag::sock. Referenced by CListeningSocket::GetOSHandle(). |
|
Definition at line 454 of file ncbi_gnutls.c. |
|
Definition at line 4405 of file ncbi_socket.c. References eListening, and LSOCK_tag::type. |
|
Definition at line 4412 of file ncbi_socket.c. References eSocket, and SOCK_tag::type. |
|
Definition at line 4398 of file ncbi_socket.c. References eTrigger, and TRIGGER_tag::type. Referenced by CSocketAPI::Poll(). |
|
Definition at line 4389 of file ncbi_socket.c. References SOCK_Poll(). |
|
Definition at line 4426 of file ncbi_socket.c. References eListening, and LSOCK_tag::type. |
|
Definition at line 4433 of file ncbi_socket.c. References eSocket, and SOCK_tag::type. |
|
Definition at line 4419 of file ncbi_socket.c. References eTrigger, and TRIGGER_tag::type. |
|
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. NB: Even though the underlying OS socket handle may have been marked for preservation via fSOCK_KeepOnClose, this call always and unconditially closes and destroys the actual OS handle.
Definition at line 4735 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_Closed, eIO_InvalidArg, eLOG_Warning, SOCK_tag::eof, SOCK_tag::pending, s_Close(), s_ID(), SOCK_tag::sock, SOCK_tag::type, and SOCK_tag::w_len. Referenced by CSocket::Abort(), s_FTPAbort(), s_FTPRetrieve(), and s_VT_Close(). |
|
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 605 of file ncbi_socket.c. Referenced by CSocketAPI::AllowSigPipe(). |
|
Close the connection, destroy 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, error flagged, or the timeout expires; if there is any output pending, that output will be flushed.
Definition at line 4234 of file ncbi_socket.c. References SOCK_CloseEx(). Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CORE_SendMailEx(), CNetBVSServer::ProcessOverflow(), CThreadedServer::ProcessOverflow(), CSocket::Reset(), s_Create(), s_DropConnection(), s_FTPAbort(), s_FTPReply(), s_VT_Close(), s_VT_Open(), s_VT_Read(), SOCK_CreateOnTopEx(), and CSocket::~CSocket(). |
|
Close the connection, and conditionally destroy relevant internal data. If eIO_Close timeout was specified (or NULL) then it blocks until either all unsent data are sent, error flagged, or the timeout expires; if there is any output pending, that output will be flushed.
Definition at line 4214 of file ncbi_socket.c. References BUF_Destroy(), eIO_Closed, eIO_Success, SOCK_tag::r_buf, s_Close(), s_Initialized, SOCK_tag::sock, and SOCK_tag::w_buf. Referenced by CListeningSocket::Accept(), CSocket::Close(), and SOCK_Close(). |
|
[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).
Definition at line 3880 of file ncbi_socket.c. References eDefault, eIO_InvalidArg, and s_Create(). Referenced by CORE_SendMailEx(). |
|
[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ select()])
Definition at line 3891 of file ncbi_socket.c. References eIO_InvalidArg, and s_Create(). Referenced by CSocket::Connect(), CSocket::CSocket(), s_VT_Open(), and URL_ConnectEx(). |
|
[SERVER-side] Create a socket on top of OS-dependent "handle". Equivalent to SOCK_CreateOnTopEx(handle, handle_size, sock, 0, 0, fSOCK_LogDefault|fSOCK_CloseOnClose).
Definition at line 3922 of file ncbi_socket.c. References fSOCK_LogDefault, and SOCK_CreateOnTopEx(). |
|
[SERVER-side] Create a socket on top of OS-dependent "handle" (file descriptor on Unix, SOCKET on MS-Windows). Returned socket is not reopenable to its default peer (SOCK_Reconnect may not specify zeros for the connection point). All timeouts are set to default [infinite] values. SOCK_Close will close the "handle" only if the "close_on_close" parameter is passed non-zero (eSCOT_CloseOnClose).
Definition at line 3930 of file ncbi_socket.c. References BUF_Destroy(), BUF_SetChunkSize(), BUF_Write(), CORE_LOGF_ERRNO_EXX, CORE_LOGF_ERRNO_X, CORE_LOGF_X, SOCKSSL_struct::Create, eDefault, eIO_Closed, eIO_InvalidArg, eIO_NotSupported, eIO_Open, eIO_Success, eIO_Unknown, eLOG_Warning, eOn, errno, eSOCK_Client, eSOCK_Server, eSocket, fSOCK_InterruptOnSignal, fSOCK_KeepOnClose, fSOCK_KeepOnExec, fSOCK_ReadOnWrite, fSOCK_Secure, NCBI_OS_DARWIN, s_DoLog(), s_ID(), s_ID_Counter, s_InitAPI(), s_Log, s_SetNonblock(), s_SSL, s_StrError(), SESSION_INVALID, SOCK_BUF_CHUNK_SIZE, and SOCK_Close(). Referenced by SOCK_CreateOnTop(). |
|
Definition at line 3905 of file ncbi_socket.c. References eIO_InvalidArg, eIO_NotSupported, and s_Create(). Referenced by CUNIXSocket::Connect(), and CUNIXSocket::CUNIXSocket(). |
|
Control OS-defined send strategy by disabling/enabling TCP Nagle algorithm that packs multiple requests into a single frame and thus transferring data in fewer transactions, miminizing the network traffic and bursting the throughput. Some applications, however, may find it useful to disable this default behavior for the sake of their performance increase (like in case of short transactions otherwise held by the system to be possibly coalesced into larger chunks).
Definition at line 4910 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, eLOG_Warning, s_ID(), and SOCK_tag::sock. Referenced by CSocket::DisableOSSendDelay(). |
|
Take INET host address (in network byte order) and fill out the the provided buffer with the name, which the address corresponds to (in case of multiple names the primary name is used).
Definition at line 5813 of file ncbi_socket.c. References CORE_LOCK_WRITE, CORE_LOGF_ERRNO_EXX, CORE_UNLOCK, DNS_BASE, EAI_BASE, eIO_Success, eLOG_Warning, eOn, s_InitAPI(), s_Log, SOCK_gethostbyname(), and SOCK_ntoa(). Referenced by ConnNetInfo_SetupStandardArgs(), CORE_SendMailEx(), CSocketAPI::gethostbyaddr(), s_MakeFrom(), and s_SetDefaultReferer(). |
|
Definition at line 5714 of file ncbi_socket.c. References CORE_LOCK_WRITE, CORE_LOGF_ERRNO_EXX, CORE_UNLOCK, DNS_BASE, EAI_BASE, eIO_Success, eLOG_Warning, eOn, out(), s_InitAPI(), s_Log, and SOCK_gethostname(). Referenced by CNetCacheServer::CNetCacheServer(), DSOCK_Connect(), DSOCK_SendMsg(), CSocketAPI::gethostbyname(), s_ClientAddress(), s_Connect(), s_ParseHeader(), SOCK_gethostbyaddr(), and SOCK_GetLocalHostAddress(). |
|
Definition at line 5601 of file ncbi_socket.c. References CORE_LOG_ERRNO_EXX, CORE_LOG_X, eIO_NotSupported, eIO_Success, and s_InitAPI(). Referenced by CNetBVSServer::CNetBVSServer(), CNetCacheServer::CNetCacheServer(), ConnNetInfo_SetupStandardArgs(), CORE_SendMailEx(), CSocketAPI::gethostname(), s_MakeFrom(), s_SetDefaultReferer(), and SOCK_gethostbyname(). |
|
Get (and cache for faster follow-up retrievals) the address of local host.
Definition at line 5943 of file ncbi_socket.c. References eDefault, eOff, eOn, SOCK_gethostbyname(), and SOCK_GetLoopbackAddress(). Referenced by g_NCBI_ConnectSrandAddend(), CSocketAPI::GetLocalHostAddress(), s_ClientAddress(), s_Open(), and SERV_ServerPort(). |
|
Get local port of the socket.
Definition at line 4779 of file ncbi_socket.c. References eNH_HostByteOrder, SOCK_tag::myport, SOCK_tag::sock, and x_GetLocalPort(). Referenced by CSocket::GetLocalPort(). |
|
Definition at line 5937 of file ncbi_socket.c. Referenced by CSocketAPI::GetLoopbackAddress(), and SOCK_GetLocalHostAddress(). |
|
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".
Definition at line 4828 of file ncbi_socket.c. References CORE_LOGF_X, eIO_Closed, eIO_InvalidArg, eIO_Success, s_ID(), and SOCK_tag::sock. Referenced by CSocket::GetOSHandle(). |
|
Get host and port of the socket's peer.
Definition at line 4796 of file ncbi_socket.c. References eNH_HostByteOrder, SOCK_tag::host, and SOCK_tag::port. Referenced by CSocket::GetPeerAddress(), and s_VT_Open(). |
|
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.
Definition at line 4812 of file ncbi_socket.c. References SOCK_tag::host, SOCK_tag::port, SOCK_HostPortToString(), and strncpy0(). Referenced by CSocket::GetPeerAddress(). |
|
Get the connection's i/o timeout (or NULL, if the timeout is infinite).
Definition at line 4471 of file ncbi_socket.c. References SOCK_tag::c_timeout, SOCK_tag::c_to, CORE_LOGF_X, eIO_Close, eIO_ReadWrite, eIO_Write, SOCK_tag::r_timeout, SOCK_tag::r_to, s_ID(), s_tv2to(), STimeout::sec, STimeout::usec, SOCK_tag::w_timeout, and SOCK_tag::w_to. Referenced by CSocket::Reset(). |
|
Print host:port into provided buffer string, not to exceed 'buflen' size. Suppress printing host if parameter 'host' is zero.
Definition at line 5999 of file ncbi_socket.c. References SOCK_ntoa(). Referenced by DSOCK_Connect(), CSocketAPI::HostPortToString(), LSOCK_Close(), s_CreateListening(), s_DoLog(), SERV_WriteInfo(), SOCK_GetPeerAddressString(), and x_ConnPoint(). |
|
See man for the BSDisms, htonl() and htons().
Definition at line 5690 of file ncbi_socket.c. Referenced by CNetCacheServer::CNetCacheServer(), CSocketAPI::HostToNetLong(), s_ParseHeader(), and s_VT_Open(). |
|
Definition at line 5696 of file ncbi_socket.c. Referenced by CSocketAPI::HostToNetShort(). |
|
Definition at line 5702 of file ncbi_socket.c. |
|
Definition at line 5708 of file ncbi_socket.c. |
|
Initialize all internal/system data & resources to be used by the SOCK API.
Definition at line 711 of file ncbi_socket.c. References CORE_LOCK_WRITE, CORE_LOG_ERRNO_EXX, CORE_UNLOCK, eIO_NotSupported, eIO_Success, eLOG_Error, s_Initialized, and SOCK_ShutdownAPI(). Referenced by CNetScheduleDApp::Init(), CSocketAPI::Initialize(), and s_InitAPI(). |
|
bool
Definition at line 5573 of file ncbi_socket.c. References eSOCK_Client, SOCK_tag::side, and SOCK_tag::sock. Referenced by CSocket::IsClientSide(). |
|
bool
Definition at line 5567 of file ncbi_socket.c. References eDatagram, SOCK_tag::sock, and SOCK_tag::type. Referenced by CSocket::IsDatagram(). |
|
Equivalent of SOCK_isip(host, 0).
Definition at line 5655 of file ncbi_socket.c. References SOCK_isipEx(). Referenced by CSocketAPI::isip(), and s_IsSufficientAddress(). |
|
Definition at line 5661 of file ncbi_socket.c. References errno. Referenced by SOCK_isip(). |
|
bool
Definition at line 5585 of file ncbi_socket.c. References SOCK_tag::session, and SOCK_tag::sock. Referenced by CSocket::IsSecure(). |
|
bool
Definition at line 5579 of file ncbi_socket.c. References eSOCK_Server, SOCK_tag::side, and SOCK_tag::sock. Referenced by CSocket::IsServerSide(), and s_Init(). |
|
bool
Definition at line 5591 of file ncbi_socket.c. References SOCK_tag::sock. Referenced by CSocket::IsUNIX(). |
|
Definition at line 5633 of file ncbi_socket.c. Referenced by CDatagramSocket::Connect(), CSocket::CSocket(), CSocketAPI::ntoa(), s_ClientAddress(), s_Open(), s_VT_Open(), SOCK_gethostbyaddr(), and SOCK_HostPortToString(). |
|
Block until at least one of the sockets enlisted in "polls" array (of size "n") becomes available for requested operation (event), or until timeout expires (wait indefinitely if timeout is passed 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.
Definition at line 4354 of file ncbi_socket.c. References BUF_Size(), eIO_Close, eIO_Closed, eIO_InvalidArg, eIO_Open, eSocket, and SSOCK_Poll::revent. Referenced by POLLABLE_Poll(). |
|
Push the specified data back to the socket input queue (in the socket's internal read buffer). These can be any data, not necessarily the data previously read from the socket.
Definition at line 4658 of file ncbi_socket.c. References CORE_LOGF_X, eIO_Closed, s_ID(), s_PushBack(), and SOCK_tag::sock. Referenced by CSocket::PushBack(), and s_SOCK_IO(). |
|
Read/peek up to "size" bytes from "sock" to the mem.buffer pointed 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 read (perhaps within the time allowance specified by eIO_Read timeout). Both mothods return any other code when no data at all were available. eIO_ReadPersist differs from the other two methods as it can return an error condition even if some data were actually obtained from the socket. Hence, as a rule of thumb, an application should always check the number of read bytes BEFORE checking the return status, which merely advises 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).
Definition at line 4508 of file ncbi_socket.c. References CORE_LOGF_X, eIO_Closed, eIO_InvalidArg, eIO_ReadPeek, eIO_ReadPersist, eIO_ReadPlain, eIO_Success, s_ID(), s_Read(), and SOCK_tag::sock. Referenced by CSocket::Read(), s_FTPAbort(), s_Read(), s_SOCK_IO(), s_SockRead(), and s_VT_Read(). |
|
Read a line from SOCK.
A line is terminated by either '
Definition at line 4642 of file ncbi_socket.c. References CORE_LOGF_X, eIO_Closed, s_ID(), s_ReadLine(), and SOCK_tag::sock. Referenced by CSocket::ReadLine(), and s_ReadReply(). |
|
[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.
Definition at line 4163 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_InvalidArg, s_ID(), s_Reconnect(), and SOCK_tag::type. Referenced by CSocket::Reconnect(), and s_VT_Open(). |
|
Control the data logging for socket "sock" individually.
Definition at line 591 of file ncbi_socket.c. References SOCK_tag::log. Referenced by CSocket::SetDataLogging(). |
|
By default ("log" == eDefault, which is eOff), data are not logged.
Definition at line 581 of file ncbi_socket.c. References eDefault, eOff, and s_Log. Referenced by CSocketAPI::SetDataLogging(). |
|
Control restartability of I/O interrupted by signals on a per-socket basis. eDefault causes the use of global API flag.
Definition at line 4879 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 ("on_off" == eDefault,eOff), I/O is restartable if interrupted.
Definition at line 4869 of file ncbi_socket.c. References eDefault, eOff, and s_InterruptOnSignal. Referenced by CSocketAPI::SetInterruptOnSignal(). |
|
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.
Definition at line 4858 of file ncbi_socket.c. References eDatagram, eDefault, SOCK_tag::r_on_w, and SOCK_tag::type. Referenced by CSocket::SetReadOnWrite(). |
|
By default ("on_off" == eDefault,eOff), 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.
Definition at line 4848 of file ncbi_socket.c. References eDefault, eOff, 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.
Definition at line 4895 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, eLOG_Warning, s_ID(), s_SetReuseAddress(), and SOCK_tag::sock. Referenced by CSocket::SetReuseAddress(). |
|
Control address reuse for socket addresses taken by the API. By default ("on_off" == eDefault,eOff), address is not marked for reuse in SOCK, but is always reused for LSOCK.
Definition at line 4887 of file ncbi_socket.c. References eOff, eOn, and s_ReuseAddress. Referenced by CSocketAPI::SetReuseAddress(). |
|
This is a helper call that can improve I/O behavior.
Definition at line 3019 of file ncbi_socket.c. References CORE_LOCK_WRITE, CORE_UNLOCK, s_SelectTimeout, s_to2tv(), and s_tv2to(). Referenced by CSocketAPI::SetSelectInternalRestartTimeout(). |
|
Specify timeout for the connection i/o (see SOCK_[Read|Write|Close] funcs). If "timeout" is NULL then set the timeout to be infinite;
Definition at line 4440 of file ncbi_socket.c. References SOCK_tag::c_timeout, SOCK_tag::c_tv, CORE_LOGF_X, eIO_Close, eIO_InvalidArg, eIO_ReadWrite, eIO_Success, eIO_Write, SOCK_tag::r_timeout, SOCK_tag::r_tv, s_ID(), s_to2tv(), SOCK_tag::w_timeout, and SOCK_tag::w_tv. Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CORE_SendMailEx(), CSocket::Reset(), s_DropConnection(), s_FTPAbort(), s_FTPExecute(), s_FTPLogin(), s_VT_Close(), s_VT_Read(), s_VT_Write(), CSocket::SetTimeout(), and URL_ConnectEx(). |
|
Definition at line 6027 of file ncbi_socket.c. References s_SSLSetup. |
|
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).
Definition at line 4193 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_Closed, eIO_InvalidArg, s_ID(), s_Shutdown(), SOCK_tag::sock, SOCK_tag::type, and SOCK_tag::w_timeout. Referenced by CSocket::Shutdown(). |
|
Cleanup; destroy all internal/system data & resources used by the SOCK API. ATTENTION: no function from the SOCK API should be called after this call!
Definition at line 801 of file ncbi_socket.c. References CORE_LOCK_WRITE, CORE_LOG_ERRNO_EXX, CORE_UNLOCK, eIO_NotSupported, eIO_Success, eLOG_Warning, SOCKSSL_struct::Exit, s_Initialized, s_SSL, and s_SSLSetup. Referenced by CId2FetchApp::Exit(), CId1FetchApp::Exit(), CSocketAPI::Shutdown(), and SOCK_InitializeAPI(). |
|
Return low-level socket I/O status of *last* socket operation. This call does not perform any I/O or socket related system calls.
Definition at line 4758 of file ncbi_socket.c. References eIO_Closed, eIO_InvalidArg, eIO_Open, eIO_Success, eIO_Timeout, eIO_Write, SOCK_tag::pending, s_Status(), and SOCK_tag::sock. Referenced by CUNIXSocket::Connect(), CSocket::Connect(), CSocket::GetStatus(), s_FTPAbort(), s_Read(), and s_VT_Status(). |
|
Read (skipping leading blanks) "[host][:port]" from a string.
Definition at line 5955 of file ncbi_socket.c. Referenced by SERV_ReadInfoEx(), and CSocketAPI::StringToHostPort(). |
|
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 succeed immediately for the datagram socket.
Definition at line 4240 of file ncbi_socket.c. References BUF_Size(), CORE_LOGF_X, eDatagram, eIO_Close, eIO_Closed, eIO_InvalidArg, eIO_Open, eIO_ReadWrite, eIO_Success, eIO_Unknown, eIO_Write, eLOG_Note, eLOG_Warning, SOCK_tag::eof, eSocket, SOCK_tag::pending, SOCK_tag::r_buf, SOCK_tag::r_status, s_ID(), s_IsConnected(), s_SelectStallsafe(), s_to2tv(), SOCK_tag::sock, SOCK_tag::type, and SOCK_tag::w_status. Referenced by CORE_SendMailEx(), s_VT_Wait(), and CSocket::Wait(). |
|
Write "size" bytes from buffer "buf" to "sock".
Definition at line 4673 of file ncbi_socket.c. References CORE_LOGF_X, eDatagram, eIO_Closed, eIO_InvalidArg, eIO_NotSupported, eIO_Success, eIO_WriteOutOfBand, eIO_WritePersist, eIO_WritePlain, s_ID(), s_Write(), SOCK_tag::sock, and SOCK_tag::type. Referenced by CNetBVSServer::ProcessOverflow(), s_FTPAbort(), s_SockWrite(), s_VT_Write(), s_WriteCommand(), and CSocket::Write(). |
|
Close an event trigger.
Definition at line 3144 of file ncbi_socket.c. References CORE_LOGF_X, eDefault, eIO_NotSupported, eIO_Success, eLOG_Trace, eOn, TRIGGER_tag::fd, TRIGGER_tag::id, TRIGGER_tag::log, and s_Log. Referenced by CTrigger::~CTrigger(). |
|
Create an event trigger.
Definition at line 3037 of file ncbi_socket.c. References CORE_LOGF_ERRNO_EXX, CORE_LOGF_ERRNO_X, CORE_LOGF_X, CORE_TRACEF, eDefault, eIO_Closed, eIO_NotSupported, eIO_Success, eIO_Unknown, eLOG_Trace, eLOG_Warning, eOn, errno, eTrigger, FALSE, s_ID_Counter, s_InitAPI(), s_Log, s_SetNonblock(), and TRUE. Referenced by CTrigger::CTrigger(). |
|
Check whether the trigger has been set. Should not be used from multiple threads concurrently at a time.
Definition at line 3210 of file ncbi_socket.c. References eIO_Closed, eIO_Success, eIO_Unknown, TRIGGER_tag::fd, and TRIGGER_tag::isset. Referenced by CTrigger::IsSet(), and TRIGGER_Reset(). |
|
Reset trigger. Should not be used from multiple threads concurently.
Definition at line 3262 of file ncbi_socket.c. References eIO_Closed, eIO_Success, eIO_Unknown, TRIGGER_tag::fd, TRIGGER_tag::isset, and TRIGGER_IsSet(). Referenced by CTrigger::Reset(). |
|
Set an event trigger. Can be used from many threads concurrently.
Definition at line 3177 of file ncbi_socket.c. References CORE_LOG_X, eIO_NotSupported, eIO_Success, eIO_Unknown, errno, TRIGGER_tag::fd, TRIGGER_tag::isset, and NCBI_SwapPointers(). Referenced by CTrigger::Set(). |