![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Socket services definitions. More...
#include <sys/types.h>#include <sys/socket.h>#include <sys/un.h>#include <netinet/in.h>#include <netdb.h>#include <arpa/inet.h>#include <unistd.h>#include <fcntl.h>#include <errno.h>#include <string.h>#include "rnr/rnrconfig.h"#include "rnr/sock.h"#include "rnr/simplebuf.h"#include "rnr/log.h"#include "rnr/new.h"Go to the source code of this file.
Classes | |
| struct | socket_t |
Macros | |
| #define | USE_IPV6 |
| enable IPV6 (Cygwin) | |
| #define | HOST_NAME_MAX 64 |
| maximum host name length | |
Functions | |
| static void | fdset_nowarn (int fd, fd_set *pset) |
| FD_SET() wrapper with no annoying warnings. More... | |
| static ushort_t | ntohs_nowarn (ushort_t huShort) |
| ntohs() wrapper with no annoying warnings. More... | |
| static ushort_t | htons_nowarn (ushort_t huShort) |
| htons() wrapper with no annoying warnings. More... | |
| static int | SockResolveHostName (const char *sHostName, struct in_addr *pAddrInet) |
| Resolve host name into IP address (IPV4 only). More... | |
| static char * | SocketAddrNameInet (int af, struct sockaddr *pAddr, const char *sHostName) |
| Allocate formated internet name (IPV4, IPV6). More... | |
| static char * | SocketAddrNameUnix (struct sockaddr_un *pAddrUnix, const char *sHostName) |
| Allocate formated UNIX name. More... | |
| static char * | SocketAddrName (struct sockaddr *pAddr, const char *sHostName) |
| Allocate formated address name. More... | |
| 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... | |
| 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... | |
Variables | |
| const char * | SockStrClosed = "** Closed **" |
| closed socket More... | |
| const char * | SockStrDisconnected = "** Disconnected **" |
| disconnected | |
| const char * | SockStrAnyHost = "ANYHOST" |
| any host | |
| const char * | SockStrLocalHost = "LOCALHOST" |
| local host | |
| const char * | SockStrUnknownHost = "UNKNOWNHOST" |
| unknown host | |
Socket services definitions.
These socket functions were inspired by the camserv socket.c functions written by Jon Travis (see below).
Socket_T *SocketOpenUnix(int ipPortUdp, int nType)
Socket_T *SocketOpenUnixPair(int nType)
fix cygwin shortcommings.
Definition in file sock.c.
|
inlinestatic |
FD_SET() wrapper with no annoying warnings.
| fd | File descriptor to add to set. |
| pset | Pointer to fd set. |
Definition at line 95 of file sock.c.
References PRAGMA_IGNORED, and PRAGMA_WARNING.
htons() wrapper with no annoying warnings.
| huShort | Unsigned short integer. |
Definition at line 117 of file sock.c.
References PRAGMA_WARNING.
Referenced by SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
ntohs() wrapper with no annoying warnings.
| huShort | Unsigned short integer. |
Definition at line 107 of file sock.c.
Referenced by SocketAddrNameInet().
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().
|
static |
Allocate formated address name.
* addrname: * addrname_inet * addrname_unix *
| pAddr | Socket address. |
| sHostName | Host name. NULLL to force lookup. |
Definition at line 347 of file sock.c.
References new_strdup(), SocketAddrNameInet(), and SocketAddrNameUnix().
Referenced by SocketAttrSetLocalName(), and SocketAttrSetRemoteName().
|
static |
Allocate formated internet name (IPV4, IPV6).
* addrname_inet:
* hostname '('dottedaddr')'
* hostname '('dottedaddr port')'
* hostname:
* given
* lookup
* dottedaddr
* dottedaddr:
* ipv4_format
* ipv6_format
* port:
* ':' number
* | af | Internet socket protocol family. |
| pAddr | Socket address. |
| sHostName | Host name. NULLL to force lookup. |
Definition at line 204 of file sock.c.
References LOGSYSERROR, NEWSTR, ntohs_nowarn(), NULL, and SockStrAnyHost.
Referenced by SocketAddrName().
|
static |
Allocate formated UNIX name.
* addrname_unix:
* hostname '('unixpath')'
* hostname:
* given
* localhost
* "LOCALHOST"
* | pAddrUnix | UNIX socket address. |
| sHostName | Host name. NULLL to force lookup. |
Definition at line 303 of file sock.c.
References NEWSTR, NULL, and SockStrLocalHost.
Referenced by SocketAddrName().
| 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().
| 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().
|
static |
Resolve host name into IP address (IPV4 only).
| sHostName | Host name in dotted or DNS network format. |
| pAddrInet | IP address |
Definition at line 155 of file sock.c.
References LOGERROR, NULL, and OK.
Referenced by SocketOpenTcpConnection(), SocketOpenTcpListener(), and SocketOpenUdp().
| const char* SockStrClosed = "** Closed **" |
closed socket
Special Host Names
Definition at line 127 of file sock.c.
Referenced by SocketAttrSetLocalName(), SocketClose(), and SocketNew().