![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Socket Sets services definitions. More...
#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <arpa/inet.h>#include <sys/time.h>#include <unistd.h>#include <errno.h>#include <string.h>#include "rnr/rnrconfig.h"#include "rnr/sock.h"#include "rnr/sockset.h"#include "rnr/log.h"#include "rnr/new.h"Go to the source code of this file.
Classes | |
| struct | sockset_t |
| Socket Set Structure. More... | |
Functions | |
| static void | fdset_nowarn (int fd, fd_set *pset) |
| FD_SET() wrapper with no annoying warnings. More... | |
| static void | fdclr_nowarn (int fd, fd_set *pset) |
| FD_CLR() wrapper with no annoying warnings. More... | |
| static int | fdisset_nowarn (int fd, fd_set *pset) |
| FD_ISSET() 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 | SockSetFindHighestSd (SockSet_T *pSockSet) |
| Find the highest socket descriptor number in the Active subset. More... | |
| static int | SockSetChkSd (Socket_T *pSocket) |
| Check if socket is open and within valid range. More... | |
| SockSet_T * | SockSetNew () |
| Allocate a new SockSet. More... | |
| void | SockSetDelete (SockSet_T *pSockSet) |
| Delete an allocated SockSet. More... | |
| int | SockSetAdd (SockSet_T *pSockSet, Socket_T *pSocket, bool_t bActivateRead, bool_t bActivateWrite) |
| Add a Socket to a SockSet. More... | |
| int | SockSetRemove (SockSet_T *pSockSet, Socket_T *pSocket) |
| Remove Socket from SockSet. More... | |
| int | SockSetActivate (SockSet_T *pSockSet, Socket_T *pSocket, bool_t bActivateRead, bool_t bActivateWrite) |
| Activate Socket read/write operations in SockSet. More... | |
| int | SockSetPutOnHold (SockSet_T *pSockSet, Socket_T *pSocket, bool_t bHoldRead, bool_t bHoldWrite) |
| Put Socket read/write operations in SockSet on hold. More... | |
| int | SockSetSelect (SockSet_T *pSockSet, struct timeval *pTimeOut) |
| Perform select() on SockSet's Active sets. More... | |
| Socket_T * | SockSetIterFirst (SockSet_T *pSockSet, int eSet, int eIO, SockSetIter_T *pIter) |
| Start iteration of Sockets in the given set in SockSet. More... | |
| Socket_T * | SockSetIterNext (SockSetIter_T *pIter) |
| Next Socket in iteration over the initialized socket set of SockSet. More... | |
Socket Sets services definitions.
A socket set is composed of three open socket read/write subsets:
| Active | SD's (socked descriptors) active for read/write I/O. |
| OnHold | SD's managed but are on hold (not select()'ed). |
| Select | The select() working subset. The Active subset is copied into the Select set and passed into select(). On select()'s return, the Select set is the subset SD's with I/O events. |
Definition in file sockset.c.
|
inlinestatic |
FD_CLR() wrapper with no annoying warnings.
| fd | File descriptor to add to set. |
| pset | Pointer to fd set. |
Definition at line 107 of file sockset.c.
Referenced by SockSetActivate(), SockSetPutOnHold(), and SockSetRemove().
|
inlinestatic |
FD_ISSET() wrapper with no annoying warnings.
| fd | File descriptor to add to set. |
| pset | Pointer to fd set. |
Definition at line 118 of file sockset.c.
References PRAGMA_IGNORED, and PRAGMA_WARNING.
Referenced by SockSetFindHighestSd(), and SockSetIterNext().
|
inlinestatic |
FD_SET() wrapper with no annoying warnings.
| fd | File descriptor to add to set. |
| pset | Pointer to fd set. |
Definition at line 97 of file sockset.c.
Referenced by SockSetActivate(), SockSetAdd(), and SockSetPutOnHold().
htons() wrapper with no annoying warnings.
| huShort | Unsigned short integer. |
Definition at line 140 of file sockset.c.
References PRAGMA_WARNING.
| int SockSetActivate | ( | SockSet_T * | pSockSet, |
| Socket_T * | pSocket, | ||
| bool_t | bActivateRead, | ||
| bool_t | bActivateWrite | ||
| ) |
Activate Socket read/write operations in SockSet.
Socket is already part of the SockSet.
| pSockSet | Pointer to SockSet. |
| pSocket | Pointer to Socket. |
| bActivateRead | Do [not] add to active read set. |
| bActivateWrite | Do [not] add to active write set. |
Definition at line 377 of file sockset.c.
References CHKPTR, fdclr_nowarn(), fdset_nowarn(), sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, OK, SOCK_IO_READ, SOCK_IO_WRITE, SOCK_RC_EBADSOCK, SockSetChkSd(), and SockSetFindHighestSd().
| int SockSetAdd | ( | SockSet_T * | pSockSet, |
| Socket_T * | pSocket, | ||
| bool_t | bActivateRead, | ||
| bool_t | bActivateWrite | ||
| ) |
Add a Socket to a SockSet.
Socket is added to either the on-hold or active socket set, depending on the given boolean value.
| pSockSet | Pointer to SockSet. |
| pSocket | Pointer to Socket. |
| bActivateRead | Do [not] add to active read set. |
| bActivateWrite | Do [not] add to active write set. |
Definition at line 272 of file sockset.c.
References _TBOOL, _TPTR, _TSTR, CHKPTR, fdset_nowarn(), LOGDIAG4CALL, sockset_t::m_pSocket, sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, OK, SOCK_IO_READ, SOCK_IO_WRITE, SOCK_RC_EBADSOCK, SocketAttrGetLocalName(), and SockSetChkSd().
|
static |
Check if socket is open and within valid range.
| pSocket | Pointer to socket. |
Definition at line 194 of file sockset.c.
References CHKPTR, LOGERROR, SOCK_RC_EBADSD, SOCK_RC_EBADSOCK, SocketAttrGetLocalName(), SocketAttrGetSd(), and SocketStateIsOpen().
Referenced by SockSetActivate(), SockSetAdd(), SockSetPutOnHold(), and SockSetRemove().
| void SockSetDelete | ( | SockSet_T * | pSockSet | ) |
|
static |
Find the highest socket descriptor number in the Active subset.
| pSockSet | Pointer to socket set. |
Definition at line 165 of file sockset.c.
References fdisset_nowarn(), sockset_t::m_sdHighest, sockset_t::m_sdSetActive, SOCK_IO_READ, and SOCK_IO_WRITE.
Referenced by SockSetActivate(), SockSetPutOnHold(), and SockSetRemove().
| Socket_T* SockSetIterFirst | ( | SockSet_T * | pSockSet, |
| int | eSet, | ||
| int | eIO, | ||
| SockSetIter_T * | pIter | ||
| ) |
Start iteration of Sockets in the given set in SockSet.
| pSockSet | Pointer to SockSet. |
| eSet | One of: SOCK_SET_ONHOLD SOCK_SET_ACTIVE SOCK_SET_SELECTED. |
| eIO | One of: SOCK_IO_READ SOCK_IO_WRITE. |
| pIter | SockSet interator. |
Definition at line 548 of file sockset.c.
References CHKPTR, SockSetIter_T::m_eIO, SockSetIter_T::m_eSet, SockSetIter_T::m_pSockSet, SockSetIter_T::m_sdCur, SockSetIter_T::m_sdSet, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, sockset_t::m_sdSetSelect, NULL, SOCK_CHK_IO, SOCK_SET_ACTIVE, SOCK_SET_CHK_SET, SOCK_SET_ONHOLD, SOCK_SET_SELECTED, and SockSetIterNext().
| Socket_T* SockSetIterNext | ( | SockSetIter_T * | pIter | ) |
Next Socket in iteration over the initialized socket set of SockSet.
| pIter | SockSet interator. |
Definition at line 587 of file sockset.c.
References CHKPTR, fdisset_nowarn(), sockset_t::m_pSocket, SockSetIter_T::m_pSockSet, SockSetIter_T::m_sdCur, SockSetIter_T::m_sdSet, and NULL.
Referenced by SockSetIterFirst().
| SockSet_T* SockSetNew | ( | ) |
Allocate a new SockSet.
Definition at line 229 of file sockset.c.
References sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, sockset_t::m_sdSetSelect, NEW, SOCK_IO_READ, and SOCK_IO_WRITE.
| int SockSetPutOnHold | ( | SockSet_T * | pSockSet, |
| Socket_T * | pSocket, | ||
| bool_t | bHoldRead, | ||
| bool_t | bHoldWrite | ||
| ) |
Put Socket read/write operations in SockSet on hold.
Socket is already part of the SockSet.
| pSockSet | Pointer to SockSet. |
| pSocket | Pointer to Socket. |
| bHoldRead | Do [not] add to hold read set. |
| bHoldWrite | Do [not] add to hold write set. |
Definition at line 429 of file sockset.c.
References CHKPTR, fdclr_nowarn(), fdset_nowarn(), sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, OK, SOCK_IO_READ, SOCK_IO_WRITE, SOCK_RC_EBADSOCK, SockSetChkSd(), and SockSetFindHighestSd().
Remove Socket from SockSet.
| pSockSet | Pointer to SockSet. |
| pSocket | Pointer to Socket. |
Definition at line 336 of file sockset.c.
References _TPTR, _TSTR, CHKPTR, fdclr_nowarn(), LOGDIAG4CALL, sockset_t::m_pSocket, sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetOnHold, NULL, OK, SOCK_IO_READ, SOCK_IO_WRITE, SOCK_RC_EBADSOCK, SocketAttrGetLocalName(), SockSetChkSd(), and SockSetFindHighestSd().
| int SockSetSelect | ( | SockSet_T * | pSockSet, |
| struct timeval * | pTimeOut | ||
| ) |
Perform select() on SockSet's Active sets.
| pSockSet | Pointer to SockSet. |
| pTimeOut | Select time out. |
Definition at line 472 of file sockset.c.
References CHKPTR, LOGERROR, LOGSYSERROR, sockset_t::m_sdHighest, sockset_t::m_sdSetActive, sockset_t::m_sdSetSelect, NULL, SOCK_IO_READ, SOCK_IO_WRITE, SOCK_RC_EBADSOCK, SOCK_RC_EFAIL, and SOCK_RC_ESYSERR.