Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cNetSocketSet Class Reference

#include <cNetSocketSet.h>

Public Member Functions

 cNetSocketSet ()
 
 cNetSocketSet (SOCKET hSocket)
 
 cNetSocketSet (const cNetSocket &socket)
 
 cNetSocketSet (const fd_set *pfds)
 
 cNetSocketSet (const cNetSocketSet &nss)
 
 ~cNetSocketSet ()
 
void operator= (const fd_set *pfds)
 
void operator= (const cNetSocketSet &nss)
 
void CopySockets (const fd_set *pfds)
 
bool AddSocket (SOCKET hSocket)
 
void RemoveSocket (SOCKET hSocket)
 
bool IsSocketSet (SOCKET hSocket) const
 
void ClearSockets () noexcept
 
int get_NFDS () const noexcept
 
void put_NFDS (int iCount) noexcept
 
 operator fd_set * ()
 
 operator const fd_set * () const
 

Static Public Member Functions

static int GRAYCALL Select (fd_set *pReadSet, fd_set *pWriteSet=nullptr, fd_set *pExceptSet=nullptr, const cTimeVal *pTimeout=nullptr)
 

Public Attributes

fd_set m_fds
 array of FD_SETSIZE possible SOCKET(s). NOTE: sizeof(m_fds) varies with FD_SETSIZE More...
 

Static Public Attributes

static const int k_nSocketSetSize = FD_SETSIZE
 = FD_SETSIZE. Max number of sockets i can add to this array. More...
 

Detailed Description

Wrapper for polling a fd_set of SOCKETs. like cOSHandleSet Max size is set to FD_SETSIZE (default=64 for _WIN32) (can be changed at compile time!)

Note
sizeof(cNetSocketSet) varies with FD_SETSIZE
linux uses this for files as well.

Constructor & Destructor Documentation

◆ cNetSocketSet() [1/5]

GrayLib::cNetSocketSet::cNetSocketSet ( )
inline

◆ cNetSocketSet() [2/5]

GrayLib::cNetSocketSet::cNetSocketSet ( SOCKET  hSocket)
inline

A socket set with a single socket.

◆ cNetSocketSet() [3/5]

GrayLib::cNetSocketSet::cNetSocketSet ( const cNetSocket socket)
inline

A socket set with a single socket.

◆ cNetSocketSet() [4/5]

GrayLib::cNetSocketSet::cNetSocketSet ( const fd_set *  pfds)
inline

Copy a socket set.

◆ cNetSocketSet() [5/5]

GrayLib::cNetSocketSet::cNetSocketSet ( const cNetSocketSet nss)
inline

Copy a socket set.

◆ ~cNetSocketSet()

GrayLib::cNetSocketSet::~cNetSocketSet ( )
inline

Member Function Documentation

◆ AddSocket()

bool GrayLib::cNetSocketSet::AddSocket ( SOCKET  hSocket)

What happens if m_fds array is full? k_nSocketSetSize/FD_SETSIZE.

◆ ClearSockets()

void GrayLib::cNetSocketSet::ClearSockets ( )
inlinenoexcept

clear the socket set.

◆ CopySockets()

void GrayLib::cNetSocketSet::CopySockets ( const fd_set *  pfds)
inline

linux FD_COPY(pfds,&m_fds);

◆ get_NFDS()

int GrayLib::cNetSocketSet::get_NFDS ( ) const
inlinenoexcept

The number of sockets in this set. sm_nSocketSetNFDS = FD_SETSIZE or Highest id of socket in the set ?

◆ IsSocketSet()

bool GrayLib::cNetSocketSet::IsSocketSet ( SOCKET  hSocket) const
inline

Some activity on the socket?

◆ operator const fd_set *()

GrayLib::cNetSocketSet::operator const fd_set * ( ) const
inline

◆ operator fd_set *()

GrayLib::cNetSocketSet::operator fd_set * ( )
inline

◆ operator=() [1/2]

void GrayLib::cNetSocketSet::operator= ( const cNetSocketSet nss)
inline

◆ operator=() [2/2]

void GrayLib::cNetSocketSet::operator= ( const fd_set *  pfds)
inline

◆ put_NFDS()

void GrayLib::cNetSocketSet::put_NFDS ( int  iCount)
inlinenoexcept

Restore the fd_count if it is cleared by a previous call to ::select()

◆ RemoveSocket()

void GrayLib::cNetSocketSet::RemoveSocket ( SOCKET  hSocket)

◆ Select()

int GRAYCALL GrayLib::cNetSocketSet::Select ( fd_set *  pReadSet,
fd_set *  pWriteSet = nullptr,
fd_set *  pExceptSet = nullptr,
const cTimeVal pTimeout = nullptr 
)
static

Any sockets have anything to do? similar to cOSHandleSet

  • pReadSet->fdcount = IS MODIFIED BY THIS CALL !!! can't just re-use set. pTimeout = is modified as timeout not used by some linux
    Returns
    returns the total number of socket handles that are ready <0 = error. SOCKET_ERROR (WSAEWOULDBLOCK) 0 = nothing.

= number of sockets that have data.

Note
under _WIN32 this is the same as WaitForMultipleObjects()? Its in a strange ws2_32.DLL. and AND MUST CALL WSAStartup()

Member Data Documentation

◆ k_nSocketSetSize

const int GrayLib::cNetSocketSet::k_nSocketSetSize = FD_SETSIZE
static

= FD_SETSIZE. Max number of sockets i can add to this array.

◆ m_fds

fd_set GrayLib::cNetSocketSet::m_fds

array of FD_SETSIZE possible SOCKET(s). NOTE: sizeof(m_fds) varies with FD_SETSIZE


The documentation for this class was generated from the following files: