GetOSHandle(
void* handle_buf,
size_thandle_size,
114 TRIGGERGetTRIGGER(
void)
const;
152 operator unsigned int(
void)
const 162 explicit operator bool(
void)
const 199 returnunsigned(lhs) == rhs
;
205 returnunsigned(lhs) != rhs
;
211 returnlhs
== unsigned(rhs);
217 returnlhs
!= unsigned(rhs);
267 CSocket(
const string& hostport,
451 size_t* n_read = 0);
476 size_t* n_written = 0,
490 booltrueport =
false)
const;
514 voidGetPeerAddress(
unsigned int* host,
515 unsigned short* port,
532 unsigned short* port,
584 voidDisableOSSendDelay(
boolon_off =
true);
592 voidSetCork(
boolon_off =
true);
602 boolIsDatagram (
void)
const;
603 boolIsClientSide(
void)
const;
604 boolIsServerSide(
void)
const;
605 boolIsUNIX (
void)
const;
606 boolIsSecure (
void)
const;
633 SOCKGetSOCK(
void)
const;
635 bool IsEmpty(
void)
const{
return!m_Socket; }
694 unsigned shortport);
705 unsigned shortport);
712 unsigned shortport);
733 string* sender_host = 0,
734 unsigned short* sender_port = 0,
735 size_tmaxmsglen = 0);
747 const string& host =
string(),
748 unsigned shortport = 0);
757 EIO_StatusSetBroadcast(
booldo_broadcast =
true);
798 unsigned shortbacklog = 64,
817 unsigned shortbacklog = 64,
859 unsigned short* port,
887 LSOCKGetLSOCK(
void)
const;
889 bool IsEmpty(
void)
const{
return!m_Socket; }
917 static size_tOSHandleSize (
void);
918 static voidAllowSigPipe (
void);
920 static EIO_StatusCloseOSHandle(
const void* handle,
925 static const STimeout* SetSelectInternalRestartTimeout
955: m_Pollable(pollable), m_Event(event), m_REvent(
eIO_Open)
970 size_t* n_ready = 0);
979 static boolisip(
const string& host,
980 boolfullquad =
false);
983eIP_HistoricIPv4 = 0,
990 static boolisip(
const string& host,
991EIP_StringKind kind = eIP_HistoricIPv4);
993 static unsigned intHostToNetLong (
unsigned int value);
994 static unsigned intNetToHostLong (
unsigned int value);
995 static unsigned shortHostToNetShort(
unsigned short value);
996 static unsigned shortNetToHostShort(
unsigned short value);
1002 static CNCBI_IPAddrgethostbyname(
const string& host,
1014 static unsigned intGetLoopbackAddress4(
void);
1020 unsigned shortport);
1025 static size_tStringToHostPort(
const string&
str,
1026 unsigned int* host,
1027 unsigned short* port);
1028 static size_tStringToHostPort(
const string&
str,
1030 unsigned short* port);
1098o_timeout(0), r_timeout(0), w_timeout(0), c_timeout(0)
1148 booltrueport)
const 1260 returnprev_ownership;
1288 unsigned shortport)
1296 const string& host,
1297 unsigned shortport)
1342 unsigned shortbacklog,
1358 unsigned shortbacklog,
1387 returnprev_ownership;
static const char * str(char *buf, int n)
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
NCBI_XNCBI_EXPORT void Abort(void)
Smart abort function.
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
bool operator!=(const CNCBI_IPAddr &lhs, unsigned int rhs)
TNCBI_BigCount GetPosition(EIO_Event direction) const
Positions and stats (direction is either eIO_Read or eIO_Write).
TNCBI_IPv6Addr * GetAddrPtr(void)
bool IsClientSide(void) const
EOwnership SetOwnership(EOwnership if_to_own)
Specify if this "CSocket" is to own the underlying "SOCK".
EIO_Status Wait(const STimeout *timeout=kInfiniteTimeout)
CPollable(const CPollable &)=delete
static ESwitch SetReadOnWrite(ESwitch read_on_write)
Defaults (see also per-socket CSocket::SetReadOnWrite, etc.)
EIO_Status Clear(EIO_Event direction)
int SOCK_isipEx(const char *host, int fullquad)
Check whether a given string represents a valid bare IPv4 address.
EIO_Status Listen(unsigned short port, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault, ESwitch ipv6=eDefault)
virtual POLLABLE GetPOLLABLE(void) const =0
static ESwitch SetIPv6(ESwitch ipv6)
ESwitch SOCK_SetReadOnWrite(SOCK sock, ESwitch on_off)
Control the reading-while-writing feature for socket "sock" individually.
bool operator==(const CNCBI_IPAddr &lhs, unsigned int rhs)
EIO_Status TRIGGER_Set(TRIGGER trigger)
Set an event trigger.
static EIO_Status Initialize(void)
Generic.
EIO_Status Shutdown(EIO_Event how)
Shutdown socket I/O in the specified direction.
int SOCK_IsSecure(SOCK sock)
Check whether a socket is using SSL (Secure Socket Layer).
CNCBI_IPAddr(unsigned int ipv4)
void SOCK_DisableOSSendDelay(SOCK sock, int on_off)
Control OS-defined send strategy by disabling/enabling the TCP Nagle algorithm (which is on by defaul...
EIO_Status SetBroadcast(bool do_broadcast=true)
static ESOCK_IOWaitSysAPI SetIOWaitSysAPI(ESOCK_IOWaitSysAPI api)
unsigned int SOCK_HostToNetLong(unsigned int value)
See man for the BSDisms, htonl() and htons().
static unsigned int HostToNetLong(unsigned int value)
EIO_Status SOCK_Shutdown(SOCK sock, EIO_Event how)
Shutdown the connection in only one direction (specified by "direction").
unsigned short SOCK_GetRemotePort(SOCK sock, ENH_ByteOrder byte_order)
Get remote port of the socket (the port it is connected to).
EIO_Status Shutdown(EIO_Event how)=delete
static size_t OSHandleSize(void)
EIO_Status Close(void)
Close socket.
EIO_Status DSOCK_SetBroadcast(SOCK sock, int broadcast)
Set a datagram socket for broadcast.
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const
Access to the system-specific socket handle.
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const =0
TNCBI_BigCount GetTotalCount(EIO_Event direction) const
CPollable * m_Pollable
[in] object pointer (or NULL not to poll)
SOCK GetSOCK(void) const
Access to the underlying "SOCK".
EIO_Status DSOCK_Connect(SOCK sock, const char *host, unsigned short port)
Associate a datagram socket with a destination address.
static unsigned int GetLoopbackAddress4(void)
TRIGGER GetTRIGGER(void) const
Access to the underlying "TRIGGER".
CNCBI_IPAddr(const TNCBI_IPv6Addr &ipv6)
ESwitch SOCK_SetReuseAddressAPI(ESwitch on_off)
Control address reuse for socket addresses taken by the API.
unsigned short GetPort(ENH_ByteOrder byte_order=eNH_HostByteOrder) const
Return port which the server listens on.
static unsigned short HostToNetShort(unsigned short value)
static void AllowSigPipe(void)
static ESwitch SetDataLogging(ESwitch log)
EIO_Status ReadLine(string &str)
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs).
unsigned short GetRemotePort(ENH_ByteOrder byte_order=eNH_HostByteOrder) const
Get socket remote port number.
static ESwitch SetReuseAddress(ESwitch reuse)
STimeout * c_timeout
eIO_Close
EIO_Status Abort(void)=delete
ESwitch SOCK_SetInterruptOnSignal(SOCK sock, ESwitch on_off)
Control restartability of I/O interrupted by signals on a per-socket basis.
CDatagramSocket(TSOCK_Flags flags=fSOCK_LogDefault)
CDatagramSocket::
EIO_Event m_REvent
[out] event ready (eIO_Open if not ready)
EIO_Status SOCK_Status(SOCK sock, EIO_Event direction)
Return low-level socket I/O status of *last* socket operation.
#define SOCK_NetToHostLong
EIO_Status SOCK_CloseOSHandle(const void *handle, size_t handle_size)
Close socket OS handle (ungracefully aborting the connection if necessary).
#define SOCK_NetToHostShort
EIO_Status TRIGGER_Reset(TRIGGER trigger)
Reset the trigger.
EIO_Status SOCK_InitializeAPI(void)
Initialize all internal/system data & resources to be used by the SOCK API.
STimeout oo_timeout
storage for o_timeout
static const STimeout * SetSelectInternalRestartTimeout(const STimeout *timeout)
Utility.
ESwitch SetInterruptOnSignal(ESwitch interrupt=eOn)
EIO_Status Reconnect(const STimeout *timeout)=delete
POLLABLE POLLABLE_FromSOCK(SOCK)
void SOCK_SetCork(SOCK sock, int on_off)
Control OS-defined send strategy by disabling/enabling the TCP layer to send incomplete network frame...
EIO_Status Connect(const string &host, unsigned short port)
void SOCK_AllowSigPipeAPI(void)
By default (on UNIX platforms) the SOCK API functions automagically call "signal(SIGPIPE,...
ENH_ByteOrder
Network and host byte order enumeration type.
ESwitch SetDataLogging(ESwitch log=eOn)
CListeningSocket(void)
CListeningSocket::
EIO_Status SOCK_CloseEx(SOCK sock, int destroy)
Close the SOCK handle, and conditionally destroy relevant internal data.
ESOCK_IOWaitSysAPI SOCK_SetIOWaitSysAPI(ESOCK_IOWaitSysAPI api)
This is a helper call that can improve I/O performance (ignored for MSVC).
unsigned int SOCK_GetLoopbackAddress(void)
Get IPv4 loopback address.
int SOCK_IsServerSide(SOCK sock)
Check whether a socket is server-side.
EOwnership SetOwnership(EOwnership if_to_own)
Specify if this "CListeningSocket" is to own the underlying "LSOCK".
unsigned short SOCK_HostToNetShort(unsigned short value)
See man for the BSDisms, htonl() and htons().
static EIO_Status Shutdown(void)
void SetReuseAddress(ESwitch reuse=eOn)
EIO_Status Abort(void)
Abort socket connection.
EIO_Status LSOCK_CreateEx6(unsigned short port, unsigned short backlog, LSOCK *lsock, TSOCK_Flags flags, ESwitch ipv6)
[SERVER-side] Create and initialize the server-side(listening) socket (socket() + bind() + listen())
CTrigger(ESwitch log=eDefault)
IMPLEMENTATION of INLINE functions.
EIO_Status Wait(EIO_Event event, const STimeout *timeout)
Wait for I/O availability in the socket.
void DisableOSSendDelay(bool on_off=true)
TNCBI_BigCount SOCK_GetPosition(SOCK sock, EIO_Event direction)
Get current read or write position within a socket.
EIO_Status GetStatus(void) const
Return eIO_Closed if not yet bound or Close()'d.
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).
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...
ESwitch SOCK_SetDataLoggingAPI(ESwitch log)
By default data are not logged.
EIO_Status SOCK_Abort(SOCK sock)
If there is outstanding connection or output data pending, cancel it.
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.
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const
Access to the system-specific handle.
static bool isip(const string &host, bool fullquad=false)
For IPv4 only.
EIP_StringKind
Broader string classificator.
EIO_Status TRIGGER_Create(TRIGGER *trigger, ESwitch log)
Create an event trigger.
ESwitch SOCK_SetReadOnWriteAPI(ESwitch on_off)
By default, sockets will not try to read data from inside SOCK_Write().
static bool IsLoopbackAddress(const CNCBI_IPAddr &addr)
ESOCK_IOWaitSysAPI
Selector of I/O wait system API: auto, poll(), or select().
STimeout cc_timeout
storage for c_timeout
static unsigned int NetToHostLong(unsigned int value)
bool IsServerSide(void) const
EIO_Status Send(const void *data, size_t datalen, const string &host=string(), unsigned short port=0)
STimeout * r_timeout
eIO_Read
EIO_Status SOCK_ReadLine(SOCK sock, char *line, size_t size, size_t *n_read)
Read a line from SOCK.
bool IsSecure(void) const
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const
Access to the system-specific socket handle.
int SOCK_IsDatagram(SOCK sock)
Check whether a socket is a datagram one.
ESwitch SOCK_SetIPv6API(ESwitch ipv6)
Select IPv6 as the underlying IP protocol.
static EIO_Status CloseOSHandle(const void *handle, size_t handle_size)
EIO_Status GetStatus(EIO_Event direction) const
Return status of *last* I/O operation without making any actual I/O.
EIO_Event m_Event
[in] event inquiry (or eIO_Open for none)
EIO_Status DSOCK_WaitMsg(SOCK sock, const STimeout *timeout)
Wait for a datagram in a datagram socket.
TNCBI_BigCount SOCK_GetTotalCount(SOCK sock, EIO_Event direction)
Get the total volume of data transferred by a socket.
TNCBI_BigCount GetCount(EIO_Event direction) const
const TNCBI_IPv6Addr & GetAddr(void) const
int SOCK_IsClientSide(SOCK sock)
Check whether a socket is client-side.
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.
virtual POLLABLE GetPOLLABLE(void) const
static unsigned short NetToHostShort(unsigned short value)
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.
EIO_Status TRIGGER_IsSet(TRIGGER trigger)
Check whether the trigger has been set.
int SOCK_IsUNIX(SOCK sock)
Check whether a socket is UNIX type.
virtual POLLABLE GetPOLLABLE(void) const
virtual POLLABLE GetPOLLABLE(void) const
TNCBI_BigCount DSOCK_GetMessageCount(SOCK sock, EIO_Event direction)
Get message count.
STimeout * o_timeout
eIO_Open
EIO_Status SOCK_ShutdownAPI(void)
Cleanup; destroy all internal/system data & resources used by the SOCK API.
EOwnership m_IsOwned
Timeouts.
ESwitch SOCK_SetDataLogging(SOCK sock, ESwitch log)
Control the data logging for socket "sock" individually.
EIO_Status Bind(unsigned short port, ESwitch ipv6=eDefault)
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 ...
EIO_Status DSOCK_CreateEx(SOCK *sock, TSOCK_Flags flags)
Create a datagram socket.
void SetCork(bool on_off=true)
unsigned short LSOCK_GetPort(LSOCK lsock, ENH_ByteOrder byte_order)
Get socket port number, which it listens on.
POLLABLE POLLABLE_FromLSOCK(LSOCK)
LSOCK GetLSOCK(void) const
Access to the underlying "LSOCK".
POLLABLE POLLABLE_FromTRIGGER(TRIGGER)
Conversion utilities from handles to POLLABLEs, and back.
int SOCK_IsLoopbackAddress6(const TNCBI_IPv6Addr *addr)
Check whether an address is a loopback one.
unsigned short GetLocalPort(ENH_ByteOrder byte_order=eNH_HostByteOrder, bool trueport=false) const
Get socket local port number.
TNCBI_BigCount GetMessageCount(EIO_Event direction) const
Message count.
size_t SOCK_OSHandleSize(void)
Get size of OS-dependent native socket handle.
EIO_Status DSOCK_Bind6(SOCK sock, unsigned short port, ESwitch ipv6)
Assosiate a datagram socket with a local port.
STimeout ww_timeout
storage for w_timeout
struct SPOLLABLE_tag * POLLABLE
ESwitch SOCK_SetInterruptOnSignalAPI(ESwitch on_off)
Control restartability of I/O interrupted by signals.
EIO_Status DSOCK_WipeMsg(SOCK sock, EIO_Event direction)
Clear message froma datagram socket.
TNCBI_BigCount SOCK_GetCount(SOCK sock, EIO_Event direction)
Get counts of read or written bytes.
static ESwitch SetInterruptOnSignal(ESwitch interrupt)
SPoll(CPollable *pollable=0, EIO_Event event=eIO_Open)
ESwitch SetReadOnWrite(ESwitch read_on_write=eOn)
const STimeout * SOCK_SetSelectInternalRestartTimeout(const STimeout *timeslice)
This is a helper call that can improve I/O behavior.
EIO_Status Pushback(const void *buf, size_t size)
Push back data to socket (to be read out first).
EIO_Status GetStatus(void) const
STimeout rr_timeout
storage for r_timeout
bool operator!(void) const
STimeout * w_timeout
eIO_Write
unsigned short SOCK_GetLocalPortEx(SOCK sock, int trueport, ENH_ByteOrder byte_order)
Get local port of the socket (true or cached / stored).
bool IsDatagram(void) const
unsigned int TSOCK_Flags
bitwise "OR" of ESOCK_Flags
@ eSAF_Full
address in full, native form
@ eIP_IPv6
Accept IPv6 notations only.
@ eIP_FullQuadIPv4
Accept full-quad IPv4 notations only.
unsigned short GetPort() const
Get the listening port number back.
enum ENcbiSwitch ESwitch
Aux.
EIO_ReadMethod
I/O read method.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
EIO_WriteMethod
I/O write method.
EIO_Event
I/O event (or direction).
uint64_t TNCBI_BigCount
Big unsigned integer for file size and position.
@ eIO_NotSupported
operation is not supported or is not available
@ eIO_Success
everything is fine, no error occurred
@ eIO_Unknown
unknown I/O error (likely fatal but can retry)
@ eIO_ReadPlain
read readily available data only, wait if none
@ eIO_WritePersist
write exactly as much as specified, w/waits
@ eIO_Open
also serves as no-event indicator in SOCK_Poll
#define NCBI_XCONNECT_EXPORT
unsigned int
A callback function used to compare two keys in a database.
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
const struct ncbi::grid::netcache::search::fields::SIZE size
static PyObject * Connect(PyObject *self, PyObject *args, PyObject *kwargs)
const GenericPointer< typename T::ValueType > T2 value
int NcbiIsEmptyIPv6(const TNCBI_IPv6Addr *addr)
Return non-zero if the address is empty (either as NULL or IPv6 or IPv4); return zero otherwise.
unsigned int NcbiIPv6ToIPv4(const TNCBI_IPv6Addr *addr, size_t pfxlen)
Extract and return a network byte order IPv4 embedded address from an IPv6 address,...
TNCBI_IPv6Addr * NcbiIPv4ToIPv6(TNCBI_IPv6Addr *addr, unsigned int ipv4, size_t pfxlen)
Embed a passed network byte order IPv4 address into an IPv6 address using the specified prefix length...
#define NCBI_XSOCK_DEPRECATED
The NCBI C++/STL use hints.
string ReadLine(CNcbiIstream &in)
The polling structure m_Event can be either of eIO_Open, eIO_Read, eIO_Write, eIO_ReadWrite.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4