|
| UT_NetSocket (UT_NetSocket &sock)=delete |
|
UT_NetSocket & | operator= (UT_NetSocket &sock)=delete |
|
bool | isSocketSelected (fd_set &set) |
|
void | addToFDSet (fd_set *set, int &maxfd) |
|
virtual | ~UT_NetSocket () |
|
virtual int64 | getMemoryUsage (bool inclusive) const |
|
virtual UT_UniquePtr
< UT_NetSocket > | accept (bool blocking, int &condition) |
|
virtual int | connect (int timeout_ms=0) |
|
virtual int | close () |
|
virtual int | shutdown (int type) |
|
virtual int | write (const void *data, int len, int *numWritten=0) |
|
virtual int | dataAvailable (int timeout=0) |
|
virtual int | read (void *data, int len, int *numRead=0, int timeout_ms=-1) |
|
virtual int | read (UT_WorkBuffer &data, int timeout_ms=-1, bool wait_for_null_terminator=false) |
|
virtual int | peek (void *data, int len, int timeout_ms=-1) |
|
virtual int | flushRead () |
|
virtual int | flushWrite () |
|
void | terminateOnConnectionLost (bool term=true) |
|
const char * | getAddress () const |
|
int | getPort () const |
|
virtual int | getRemoteSocket (UT_IpAddressV4 &host, int &port) const |
|
virtual int | setBlocking (bool blocking) |
|
bool | isBlocking () const |
|
void | setNoDelay (int usenodelay) |
|
void | setQuickAck (int quickack) |
|
virtual bool | isValid () const |
|
bool | isServer () const |
|
bool | isConnected () const |
|
int | getSocket () const |
|
const UT_IpAddressV4 & | getRemoteIP4 () const |
|
bool | getRemoteIP4 (UT_IpAddressV4 &ip) |
|
UT_IpAddressV4 | getLocalIP4 () const |
|
bool | getLocalIP4 (UT_IpAddressV4 &ip) |
|
SYS_NO_DISCARD_RESULT bool | isLocalConnection () const |
|
int | sockRecv (void *data, int len, int *num_read=nullptr) |
|
|
static const char * | getErrorName (int code) |
|
static int | getPortByService (const char *service, const char *proto="tcp", int default_port=0) |
|
static void | getHostName (char *name, int max) |
|
static bool | getHostAddress (UT_IpAddressV4 &address, const char *hostname=0) |
|
static bool | getHostAddress (UT_IpAddress &address, const char *hostname=0) |
|
static bool | getLocalAddresses (UT_Array< UT_IpAddress > &addresses, UT_IpAddressFamily family=UT_IpAddressFamily::IPv4) |
|
static bool | getLocalAddress (UT_IpAddress &address, UT_IpAddressFamily family=UT_IpAddressFamily::IPv4) |
|
static bool | getHostNameByAlias (UT_String &host, const char *alias=NULL) |
|
static int | mapToUnprivilegedPort (int port) |
|
static bool | sendCommandAndGetResult (int port, const char *command, UT_WorkBuffer &response, const char *host_name=0, bool remap_privileged_ports=true) |
|
static bool | nonBlockingSendCommandAndGetResult (int port, const char *command, UT_WorkBuffer &response, const char *host_name=0, bool remap_privileged_ports=true) |
|
static UT_UniquePtr< UT_NetSocket > | newSocket (int port, bool blocking=false, bool portisonlyhint=false) |
|
static UT_UniquePtr< UT_NetSocket > | newSocketFromAddr (const char *address, int port, bool blocking=false, int localport=-1) |
|
static void | fdZero (fd_set *set) |
|
static void | fdSet (int fd, fd_set *set) |
|
static void | fdClr (int fd, fd_set *set) |
|
static int | fdIsSet (int fd, fd_set *set) |
|
static int | select (int fd, fd_set *r_set, fd_set *w_set, fd_set *e_set, SYS_TimeVal *tv) |
|
static int | selectInMS (int maxfd, fd_set *r_set, fd_set *w_set, fd_set *e_set, int timeoutms=0) |
|
static SYS_NO_DISCARD_RESULT bool | isLocalConnection (int fd) |
|
Use NET_TCPSocket instead of UT_NetSocket. UT_NetSocket has a lot of short comings when something unexpected occurs. UT_NetSocket also doesnt support async very well. Additionally, its very difficult to get proper error information when something goes wrong.
Definition at line 38 of file UT_NetSocket.h.
static int UT_NetSocket::select |
( |
int |
fd, |
|
|
fd_set * |
r_set, |
|
|
fd_set * |
w_set, |
|
|
fd_set * |
e_set, |
|
|
SYS_TimeVal * |
tv |
|
) |
| |
|
static |
Performs a select() call on the socket.
Note, it turns out there is a discrepancy between how select() works on Linux vs. Windows.
On Windows, the select() call selects for reading the sockets even if they were closed by the remote counterparts. The rationale is that trying to read from such a socket returns zero, which is a signal that the connection was closed.
On Linux/OSX, select() call does not select such sockets for reading. The rationale is that there cannot be any more data for reading on closed sockets.