![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Socket services declarations. More...
#include <sys/types.h>#include <sys/socket.h>#include "rnr/rnrconfig.h"#include "rnr/log.h"#include "rnr/simplebuf.h"Go to the source code of this file.
Macros | |
| #define | USE_IPV6 |
| #define | SOCK_RC_OK 0 |
| no error | |
| #define | SOCK_RC_EFAIL (-1) |
| general, unspecified error | |
| #define | SOCK_RC_IODONE (-2) |
| finished current I/O | |
| #define | SOCK_RC_EBUFFULL (-3) |
| buffer is full | |
| #define | SOCK_RC_EBADSOCK (-4) |
| socket is bad | |
| #define | SOCK_RC_ENOBUF (-5) |
| no buffer | |
| #define | SOCK_RC_EBADSD (-6) |
| bad/closed socket descriptor | |
| #define | SOCK_RC_ESYSERR (-7) |
| system error occurred | |
| #define | SOCK_IO_READ 0 |
| read index | |
| #define | SOCK_IO_WRITE 1 |
| write index | |
| #define | SOCK_IO_NUMOF 2 |
| number of indices | |
| #define | SOCK_CHK_IO(io, ...) CHKEXPR_INT(io, ((io) >= 0) && ((io) < SOCK_IO_NUMOF), __VA_ARGS__) |
| Check I/O index. More... | |
| #define | SOCK_SD_CLOSED (-1) |
| closed socket descriptor value | |
| #define | SOCK_PORT_NONE (-1) |
| no port number specified | |
Typedefs | |
| typedef struct socket_t | Socket_T |
| the Socket | |
Enumerations | |
| enum | SockFlavor { SockFlavorUndef = 0x0000, SockFlavorDomainIPv4 = 0x0001, SockFlavorDomainIPv6 = 0x0002, SockFlavorDomainUnix = 0x0003, SockFlavorDomainMask = 0x0003, SockFlavorProtocolTcp = 0x0004, SockFlavorProtocolUdp = 0x0008, SockFlavorProtocolMask = 0x000C, SockFlavorFuncListener = 0x0010, SockFlavorFuncConnection = 0x0020, SockFlavorFuncMask = 0x0030 } |
| < unit tests More... | |
Functions | |
| char * | SocketThisHostName () |
| Get the host string name of this network node (computer). More... | |
| Socket_T * | SocketNew () |
| Allocate a new, unconnected socket. More... | |
| void | SocketDelete (Socket_T *pSocket) |
| Delate an allocated socket. More... | |
| SimpleBuf_T * | SocketBufNewBuf (Socket_T *pSocket, int eIOBuf, size_t nBufSize) |
| Allocate a socket buffer and attach to Socket. More... | |
| SimpleBuf_T * | SocketBufSetBuf (Socket_T *pSocket, int eIOBuf, byte_t *pBuf, size_t nBufSize) |
| Attach a buffer to Socket. More... | |
| SimpleBuf_T * | SocketBufGetBuf (Socket_T *pSocket, int eIOBuf) |
| Get Socket buffer. More... | |
| byte_t * | SocketBufGetRawBuf (Socket_T *pSocket, int eIOBuf) |
| Get Socket raw buffer. More... | |
| size_t | SocketBufGetSize (Socket_T *pSocket, int eIOBuf) |
| Get Socket buffer size. More... | |
| size_t | SocketBufGetLen (Socket_T *pSocket, int eIOBuf) |
| Get number of bytes in Socket buffer. More... | |
| void | SocketBufClear (Socket_T *pSocket, int eIOBuf) |
| Clear a Socket buffer. More... | |
| void * | SocketAttrGetClientData (Socket_T *pSocket) |
| Get Socket client user data. More... | |
| void | SocketAttrSetClientData (Socket_T *pSocket, void *pClientData) |
| Get Socket client user data. More... | |
| const char * | SocketAttrGetLocalName (Socket_T *pSocket) |
| Get Socket local name. More... | |
| void | SocketAttrSetLocalName (Socket_T *pSocket, const char *sHostName) |
| Set Socket local name. More... | |
| const char * | SocketAttrGetRemoteName (Socket_T *pSocket) |
| Get Socket remote name. More... | |
| void | SocketAttrSetRemoteName (Socket_T *pSocket, struct sockaddr *pAddr, const char *sHostName) |
| Set Socket remote name. More... | |
| int | SocketAttrGetSd (Socket_T *pSocket) |
| Get Socket socket (file) descriptor. More... | |
| void | SocketAttrSetSd (Socket_T *pSocket, int sd) |
| Set Socket socket (file) descriptor. More... | |
| int | SocketAttrGetPort (Socket_T *pSocket) |
| Get Socket port number. More... | |
| void | SocketAttrSetPort (Socket_T *pSocket, int ipPort) |
| Set Socket port number. More... | |
| SockFlavor | SocketAttrGetFlavor (Socket_T *pSocket) |
| Get Socket flavor. More... | |
| void | SocketAttrSetFlavor (Socket_T *pSocket, SockFlavor eFlavor) |
| Set Socket flavor. More... | |
| bool_t | SocketAttrHasFlavor (Socket_T *pSocket, int nMask, int nFlavor) |
| Check if Socket has an assigned flavor. More... | |
| INLINE_IN_H bool_t | SocketAttrIsListener (Socket_T *pSocket) |
| Test if socket is a listener flavor. More... | |
| INLINE_IN_H bool_t | SocketAttrIsConnection (Socket_T *pSocket) |
| Test if socket is connection flavor. More... | |
| INLINE_IN_H bool_t | SocketAttrIsConnectionless (Socket_T *pSocket) |
| Test if socket is connectionless flavor. More... | |
| int | SocketAttrSetNonBlocking (Socket_T *pSocket) |
| Set Socket for non-blockiong I/O. More... | |
| bool_t | SocketStateIsOpen (Socket_T *pSocket) |
| Check if Socket is open. More... | |
| bool_t | SocketStateIsErrored (Socket_T *pSocket) |
| Check if Socket is in some kind of errored state. More... | |
| Socket_T * | SocketOpenTcpListener (int ipPortListener, const char *sLocalHostName) |
| Create and open a new TCP/IP passive listener socket on this host. More... | |
| Socket_T * | SocketOpenTcpConnection (const char *sRemoteHostName, int ipPortRemote) |
| Create and open a new TCP/IP socket to the given remote host and port. More... | |
| Socket_T * | SocketOpenUdp (int ipPortUdp, const char *sLocalHostName) |
| Create and open a new UDP/IP connectionless socket. port. More... | |
| Socket_T * | SocketOpenUnix (int ipPortUdp, int nType) |
| Create and open a new UNIX connectionless socket. More... | |
| Socket_T * | SocketOpenUnixPair (int nType) |
| Create and open a new UNIX pair socket. More... | |
| Socket_T * | SocketAccept (Socket_T *pSocketListener, bool_t bNonBlock) |
| Accept a client connection requst from the listener socket. More... | |
| int | SocketClose (Socket_T *pSocket) |
| Close a Socket. More... | |
| ssize_t | SocketRead (Socket_T *pSocket) |
| Reads the next available bytes from the Socket into in the Socket's read buffer. More... | |
| ssize_t | SocketWrite (Socket_T *pSocket) |
| Writes the bytes from the Socket's write buffer to the Socket connection. More... | |
| ssize_t | SocketWriteAll (Socket_T *pSocket) |
| Writes all of the bytes from the socket's write buffer until no more bytes or error. More... | |
Socket services declarations.
These socket functions were inspired by the camserv socket.c functions written by Jon Travis (see below).
—
Definition in file sock.h.
| #define SOCK_CHK_IO | ( | io, | |
| ... | |||
| ) | CHKEXPR_INT(io, ((io) >= 0) && ((io) < SOCK_IO_NUMOF), __VA_ARGS__) |
Check I/O index.
| io | I/O buffer index |
Definition at line 138 of file sock.h.
Referenced by SocketBufClear(), SocketBufGetBuf(), SocketBufGetLen(), SocketBufGetRawBuf(), SocketBufGetSize(), SocketBufNewBuf(), SocketBufSetBuf(), and SockSetIterFirst().
| enum SockFlavor |
< unit tests
< general debugging
Socket Flavors (a distillation of the various POSIX domains, families, protocals, and types).
Definition at line 88 of file sock.h.
Accept a client connection requst from the listener socket.
The new socket will be set to non-blocking I/O mode if requested.
| pSocketListener | Pointer to open listener socket. |
| bNonBlock | Do [not] set socket to non-blocking. |
Return Value: Newly allocated and accepted open Socket_T pointer on success, NULL on failure.
Definition at line 1240 of file sock.c.
References LOGDIAG4, LOGDIAG4CALL, LOGERROR, LOGSYSERROR, socket_t::m_sd, socket_t::m_sLocalName, NULL, SocketAttrGetRemoteName(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetNonBlocking(), SocketAttrSetPort(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SocketClose(), SocketDelete(), SocketNew(), SockFlavorDomainIPv4, SockFlavorFuncConnection, and SockFlavorProtocolTcp.
Referenced by SocketAttrIsConnectionless().
| void* SocketAttrGetClientData | ( | Socket_T * | pSocket | ) |
Get Socket client user data.
| pSocket | Pointer to Socket. |
Definition at line 607 of file sock.c.
References CHKPTR, socket_t::m_pClientData, and NULL.
| SockFlavor SocketAttrGetFlavor | ( | Socket_T * | pSocket | ) |
Get Socket flavor.
| pSocket | Pointer to Socket. |
Definition at line 788 of file sock.c.
References CHKPTR, socket_t::m_eFlavor, and SockFlavorUndef.
| const char* SocketAttrGetLocalName | ( | Socket_T * | pSocket | ) |
Get Socket local name.
| pSocket | Pointer to Socket. |
Definition at line 632 of file sock.c.
References CHKPTR, socket_t::m_sLocalName, and NULL.
Referenced by SocketClose(), SocketOpenTcpListener(), SocketOpenUdp(), SocketWriteAll(), SockSetAdd(), SockSetChkSd(), and SockSetRemove().
| int SocketAttrGetPort | ( | Socket_T * | pSocket | ) |
Get Socket port number.
| pSocket | Pointer to Socket. |
Definition at line 763 of file sock.c.
References CHKPTR, socket_t::m_ipPort, and SOCK_PORT_NONE.
| const char* SocketAttrGetRemoteName | ( | Socket_T * | pSocket | ) |
Get Socket remote name.
| pSocket | Pointer to Socket. |
Definition at line 682 of file sock.c.
References CHKPTR, socket_t::m_sRemoteName, and NULL.
Referenced by SocketAccept(), SocketClose(), SocketOpenTcpConnection(), and SocketWriteAll().
| int SocketAttrGetSd | ( | Socket_T * | pSocket | ) |
Get Socket socket (file) descriptor.
| pSocket | Pointer to Socket. |
Definition at line 735 of file sock.c.
References CHKPTR, socket_t::m_sd, and SOCK_SD_CLOSED.
Referenced by SockSetChkSd().
Check if Socket has an assigned flavor.
| pSocket | Pointer to Socket. |
| nMask | Flavor mask of relevant bits. |
| nFlavor | Flavor bits. |
Definition at line 815 of file sock.c.
References CHKPTR, socket_t::m_eFlavor, socket_t::m_sd, and SOCK_SD_CLOSED.
Referenced by SocketAttrIsConnection(), and SocketAttrIsListener().
| INLINE_IN_H bool_t SocketAttrIsConnection | ( | Socket_T * | pSocket | ) |
Test if socket is connection flavor.
| pSocket | Pointer to socket. |
Definition at line 252 of file sock.h.
References SocketAttrHasFlavor(), SockFlavorFuncConnection, and SockFlavorFuncMask.
Referenced by SocketAttrIsConnectionless(), and SocketClose().
| INLINE_IN_H bool_t SocketAttrIsConnectionless | ( | Socket_T * | pSocket | ) |
Test if socket is connectionless flavor.
| pSocket | Pointer to socket. |
Definition at line 266 of file sock.h.
References C_DECLS_END, SocketAccept(), SocketAttrIsConnection(), SocketAttrSetNonBlocking(), SocketClose(), SocketOpenTcpConnection(), SocketOpenTcpListener(), SocketOpenUdp(), SocketOpenUnix(), SocketOpenUnixPair(), SocketRead(), SocketStateIsErrored(), SocketStateIsOpen(), SocketWrite(), and SocketWriteAll().
| INLINE_IN_H bool_t SocketAttrIsListener | ( | Socket_T * | pSocket | ) |
Test if socket is a listener flavor.
| pSocket | Pointer to socket. |
Definition at line 238 of file sock.h.
References SocketAttrHasFlavor(), SockFlavorFuncListener, and SockFlavorFuncMask.
| void SocketAttrSetClientData | ( | Socket_T * | pSocket, |
| void * | pClientData | ||
| ) |
Get Socket client user data.
| pSocket | Pointer to Socket. |
| pClientData | User defined data. |
Definition at line 619 of file sock.c.
References CHKPTR, and socket_t::m_pClientData.
| void SocketAttrSetFlavor | ( | Socket_T * | pSocket, |
| SockFlavor | eFlavor | ||
| ) |
Set Socket flavor.
| pSocket | Pointer to Socket. |
| eFlavor | Flavor enumeration. |
Definition at line 800 of file sock.c.
References CHKPTR, and socket_t::m_eFlavor.
Referenced by SocketAccept(), SocketClose(), SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| void SocketAttrSetLocalName | ( | Socket_T * | pSocket, |
| const char * | sHostName | ||
| ) |
Set Socket local name.
| pSocket | Pointer to Socket. |
| sHostName | Local host name string. |
Definition at line 644 of file sock.c.
References CHKPTR, LOGSYSERROR, socket_t::m_sd, socket_t::m_sLocalName, new_strdup(), SocketAddrName(), SocketStateIsOpen(), and SockStrClosed.
Referenced by SocketAccept(), SocketClose(), SocketNew(), SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| int SocketAttrSetNonBlocking | ( | Socket_T * | pSocket | ) |
Set Socket for non-blockiong I/O.
| pSocket | Pointer to Socket. |
Definition at line 837 of file sock.c.
References CHKPTR, LOGDIAG3, LOGSYSERROR, socket_t::m_sd, and OK.
Referenced by SocketAccept(), and SocketAttrIsConnectionless().
| void SocketAttrSetPort | ( | Socket_T * | pSocket, |
| int | ipPort | ||
| ) |
Set Socket port number.
| pSocket | Pointer to Socket. |
| ipPort | Port number. |
Definition at line 775 of file sock.c.
References CHKPTR, and socket_t::m_ipPort.
Referenced by SocketAccept().
| void SocketAttrSetRemoteName | ( | Socket_T * | pSocket, |
| struct sockaddr * | pAddr, | ||
| const char * | sHostName | ||
| ) |
Set Socket remote name.
| pSocket | Pointer to Socket. |
| pAddr | Socket address. |
| sHostName | Remote host name string. |
Definition at line 695 of file sock.c.
References CHKPTR, socket_t::m_sRemoteName, new_strdup(), NULL, SocketAddrName(), SocketStateIsOpen(), and SockStrDisconnected.
Referenced by SocketAccept(), SocketClose(), SocketNew(), SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| void SocketAttrSetSd | ( | Socket_T * | pSocket, |
| int | sd | ||
| ) |
Set Socket socket (file) descriptor.
| pSocket | Pointer to Socket. |
| sd | Socket descriptor. |
Definition at line 747 of file sock.c.
References CHKPTR, socket_t::m_sd, and SocketClose().
Referenced by SocketAccept(), SocketClose(), SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| void SocketBufClear | ( | Socket_T * | pSocket, |
| int | eIOBuf | ||
| ) |
Clear a Socket buffer.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
Definition at line 587 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, SimpleBufClear(), and SOCK_CHK_IO.
| SimpleBuf_T* SocketBufGetBuf | ( | Socket_T * | pSocket, |
| int | eIOBuf | ||
| ) |
Get Socket buffer.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
Definition at line 525 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, NULL, and SOCK_CHK_IO.
| size_t SocketBufGetLen | ( | Socket_T * | pSocket, |
| int | eIOBuf | ||
| ) |
Get number of bytes in Socket buffer.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
Definition at line 573 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, SimpleBufHasLen(), and SOCK_CHK_IO.
Get Socket raw buffer.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
Definition at line 541 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, SimpleBuf_T::m_pRWBuf, NULL, and SOCK_CHK_IO.
| size_t SocketBufGetSize | ( | Socket_T * | pSocket, |
| int | eIOBuf | ||
| ) |
Get Socket buffer size.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
Definition at line 557 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, SimpleBufHasSize(), and SOCK_CHK_IO.
| SimpleBuf_T* SocketBufNewBuf | ( | Socket_T * | pSocket, |
| int | eIOBuf, | ||
| size_t | nBufSize | ||
| ) |
Allocate a socket buffer and attach to Socket.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
| nBufSize | Buffer size (bytes). |
Definition at line 485 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, NULL, SimpleBufDelete(), SimpleBufNewWithBuf(), and SOCK_CHK_IO.
| SimpleBuf_T* SocketBufSetBuf | ( | Socket_T * | pSocket, |
| int | eIOBuf, | ||
| byte_t * | pBuf, | ||
| size_t | nBufSize | ||
| ) |
Attach a buffer to Socket.
| pSocket | Pointer to Socket. |
| eIOBuf | One of: SOCK_IO_READ SOCK_IO_WRITE. |
| pBuf | Pointer to buffer. |
| nBufSize | Buffer size (bytes). |
Definition at line 505 of file sock.c.
References CHKPTR, socket_t::m_pIOBuf, NULL, SimpleBufSetBuf(), and SOCK_CHK_IO.
| int SocketClose | ( | Socket_T * | pSocket | ) |
Close a Socket.
| pSocket | Pointer to Socket. |
Definition at line 1292 of file sock.c.
References CHKPTR, LOGDIAG4, LOGSYSERROR, socket_t::m_sd, NULL, SOCK_SD_CLOSED, SocketAttrGetLocalName(), SocketAttrGetRemoteName(), SocketAttrIsConnection(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SockFlavorUndef, SockStrClosed, and SockStrDisconnected.
Referenced by SocketAccept(), SocketAttrIsConnectionless(), SocketAttrSetSd(), and SocketWriteAll().
| void SocketDelete | ( | Socket_T * | pSocket | ) |
Delate an allocated socket.
Definition at line 457 of file sock.c.
References socket_t::m_pIOBuf, socket_t::m_sLocalName, socket_t::m_sRemoteName, NULL, SimpleBufDelete(), SOCK_IO_READ, and SOCK_IO_WRITE.
Referenced by SocketAccept(), and SocketWriteAll().
| Socket_T* SocketNew | ( | ) |
Allocate a new, unconnected socket.
Definition at line 433 of file sock.c.
References socket_t::m_eFlavor, socket_t::m_ipPort, socket_t::m_pClientData, socket_t::m_pIOBuf, socket_t::m_sd, NEW, NULL, SimpleBufNew(), SOCK_IO_READ, SOCK_IO_WRITE, SOCK_PORT_NONE, SOCK_SD_CLOSED, SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SockFlavorUndef, SockStrClosed, and SockStrDisconnected.
Referenced by SocketAccept(), SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| Socket_T* SocketOpenTcpConnection | ( | const char * | sRemoteHostName, |
| int | ipPortRemote | ||
| ) |
Create and open a new TCP/IP socket to the given remote host and port.
| sRemoteHostName | Dotted address or network name. |
| ipPortRemote | Remote port number. |
Definition at line 1059 of file sock.c.
References htons_nowarn(), LOGDIAG4, LOGERROR, LOGSYSERROR, NULL, SocketAttrGetRemoteName(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SocketNew(), SockFlavorDomainIPv4, SockFlavorFuncConnection, SockFlavorProtocolTcp, and SockResolveHostName().
Referenced by SocketAttrIsConnectionless(), and SocketWriteAll().
| Socket_T* SocketOpenTcpListener | ( | int | ipPortListener, |
| const char * | sLocalHostName | ||
| ) |
Create and open a new TCP/IP passive listener socket on this host.
| ipPortListener | Port number to listen on. |
| sLocalHostName | String name of local host to bind to. If NULL, then this host will automatically choose the IP address. |
Definition at line 942 of file sock.c.
References _TINT, _TSTR, htons_nowarn(), LOGDIAG4, LOGDIAG4CALL, LOGERROR, LOGSYSERROR, NULL, SocketAttrGetLocalName(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SocketNew(), SockFlavorDomainIPv4, SockFlavorFuncListener, SockFlavorProtocolTcp, SockResolveHostName(), and SockStrAnyHost.
Referenced by SocketAttrIsConnectionless(), and SocketWriteAll().
| Socket_T* SocketOpenUdp | ( | int | ipPortUdp, |
| const char * | sLocalHostName | ||
| ) |
Create and open a new UDP/IP connectionless socket. port.
| ipPortUdp | Binding UDP port number. |
| sLocalHostName | String name of local host to bind to. If NULL, then this host will automatically choose the IP address. |
Definition at line 1126 of file sock.c.
References _TINT, _TSTR, htons_nowarn(), LOGDIAG4, LOGDIAG4CALL, LOGERROR, LOGSYSERROR, NULL, SocketAttrGetLocalName(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SocketNew(), SockFlavorDomainIPv4, SockFlavorProtocolUdp, SockResolveHostName(), and SockStrAnyHost.
Referenced by SocketAttrIsConnectionless(), and SocketWriteAll().
| Socket_T* SocketOpenUnix | ( | int | ipPortUdp, |
| int | nType | ||
| ) |
Create and open a new UNIX connectionless socket.
| ipPortUdp | Binding UDP port number. |
| nType | Type of... |
Definition at line 1208 of file sock.c.
References NULL.
Referenced by SocketAttrIsConnectionless().
| Socket_T* SocketOpenUnixPair | ( | int | nType | ) |
Create and open a new UNIX pair socket.
| nType | Type of... |
Definition at line 1223 of file sock.c.
References NULL.
Referenced by SocketAttrIsConnectionless().
| ssize_t SocketRead | ( | Socket_T * | pSocket | ) |
Reads the next available bytes from the Socket into in the Socket's read buffer.
| pSocket | Pointer to Socket. |
Definition at line 1340 of file sock.c.
References CHKPTR, LOGDIAG4, LOGERROR, LOGSYSERROR, socket_t::m_pIOBuf, SimpleBuf_T::m_pRWBuf, socket_t::m_sd, socket_t::m_sLocalName, SIMPLEBUF_REL, SimpleBufGetWritePtr(), SimpleBufHasAvail(), SimpleBufWriteSeek(), SOCK_IO_READ, SOCK_RC_EBADSD, SOCK_RC_EBADSOCK, SOCK_RC_EBUFFULL, SOCK_RC_ENOBUF, SOCK_RC_ESYSERR, and SocketStateIsOpen().
Referenced by SocketAttrIsConnectionless().
Check if Socket is in some kind of errored state.
The fcntl() non-blocking function is used to test the socket.
| pSocket | Pointer to Socket. |
Definition at line 909 of file sock.c.
References socket_t::m_sd, NULL, and SOCK_SD_CLOSED.
Referenced by SocketAttrIsConnectionless().
Check if Socket is open.
| pSocket | Pointer to Socket. |
Definition at line 888 of file sock.c.
References socket_t::m_sd, NULL, and SOCK_SD_CLOSED.
Referenced by SocketAttrIsConnectionless(), SocketAttrSetLocalName(), SocketAttrSetRemoteName(), SocketRead(), SocketWrite(), and SockSetChkSd().
| char* SocketThisHostName | ( | ) |
Get the host string name of this network node (computer).
Definition at line 379 of file sock.c.
References HOST_NAME_MAX, LOGERROR, LOGSYSERROR, new_strdup(), NEWSTR, NULL, and SockStrUnknownHost.
| ssize_t SocketWrite | ( | Socket_T * | pSocket | ) |
Writes the bytes from the Socket's write buffer to the Socket connection.
Only one write attempt is made.
| pSocket | Pointer to Socket. |
Definition at line 1409 of file sock.c.
References CHKPTR, LOGERROR, LOGSYSERROR, socket_t::m_pIOBuf, SimpleBuf_T::m_pRWBuf, socket_t::m_sd, SIMPLEBUF_REL, SimpleBufGetReadPtr(), SimpleBufHasLen(), SimpleBufReadSeek(), SOCK_IO_WRITE, SOCK_RC_EBADSD, SOCK_RC_EBADSOCK, SOCK_RC_ENOBUF, SOCK_RC_ESYSERR, SOCK_RC_IODONE, and SocketStateIsOpen().
Referenced by SocketAttrIsConnectionless(), and SocketWriteAll().
| ssize_t SocketWriteAll | ( | Socket_T * | pSocket | ) |
Writes all of the bytes from the socket's write buffer until no more bytes or error.
| pSocket | Pointer to Socket. |
Definition at line 1472 of file sock.c.
References LOGDIAG4, LOGERROR, NULL, SOCK_RC_IODONE, SocketAttrGetLocalName(), SocketAttrGetRemoteName(), SocketClose(), SocketDelete(), SocketOpenTcpConnection(), SocketOpenTcpListener(), SocketOpenUdp(), and SocketWrite().
Referenced by SocketAttrIsConnectionless().