#include <cNetSocket.h>
|
| cNetSocketBase () |
|
virtual | ~cNetSocketBase () |
|
virtual bool | isValidCheck () const noexcept |
| < memory allocation and structure definitions are valid. More...
|
|
bool | isValidSocket () const noexcept |
|
| operator SOCKET () const noexcept |
|
bool | AttachSocket (SOCKET hSocket) |
|
SOCKET | DetachSocket () |
|
virtual void | Close () |
|
bool | Listen (int iMaxBacklogConnections=SOMAXCONN) |
|
int | Send (const void *pData, int iLen, int nFlags=0) |
|
int | Receive (void *pBuffer, int nBufLen, int nFlags=0) |
|
bool | IOCtl (long lCmd, unsigned long *pnArgs) const |
|
bool | SetSockOpt (int nOptionName, const void *optval, socklen_t optlen, int nLevel=SOL_SOCKET) const |
|
bool | GetSockOpt (int nOptionName, void *optval, socklen_t *pOptLen, int nLevel=SOL_SOCKET) const |
|
virtual | ~CObject () |
|
virtual void | AssertValid () const |
| < memory allocation and structure definitions are valid. More...
|
|
virtual void | Serialize (cArchive &a) |
|
Wrapper for raw OS SOCKET. OS level of buffering only. mimic MFC CSocket/CAsyncSocket as a base class for cNetSocket
◆ cNetSocketBase()
GrayLib::cNetSocketBase::cNetSocketBase |
( |
| ) |
|
◆ ~cNetSocketBase()
GrayLib::cNetSocketBase::~cNetSocketBase |
( |
| ) |
|
|
virtual |
- Note
- Virtuals don't work properly here!
◆ AttachSocket()
bool GrayLib::cNetSocketBase::AttachSocket |
( |
SOCKET |
hSocket | ) |
|
Manage a socket created from some other mechanism. AKA Attach() in MFC
◆ Close()
void GrayLib::cNetSocketBase::Close |
( |
| ) |
|
|
virtual |
◆ Connect()
bool GrayLib::cNetSocketBase::Connect |
( |
const struct sockaddr * |
pAddr, |
|
|
socklen_t |
nAddrLen |
|
) |
| |
|
inlineprotected |
With a nonblocking socket, the connection attempt cannot be completed immediately. In this case, connect will return SOCKET_ERROR
◆ DetachSocket()
SOCKET GrayLib::cNetSocketBase::DetachSocket |
( |
| ) |
|
AKA Detach() in MFC the caller now owns the socket. not auto destroyed. no close.
◆ get_HSocket()
SOCKET GrayLib::cNetSocketBase::get_HSocket |
( |
| ) |
const |
|
inlineprotectednoexcept |
Get the low level socket handle.
◆ GetSockOpt()
bool GrayLib::cNetSocketBase::GetSockOpt |
( |
int |
nOptionName, |
|
|
void * |
optval, |
|
|
socklen_t * |
pOptLen, |
|
|
int |
nLevel = SOL_SOCKET |
|
) |
| const |
nLevel = SOL_SOCKET or IPPROTO_TCP. (same as nProtocolType in socket() ??) nOptionName = SO_CONNECT_TIME
◆ IOCtl()
bool GrayLib::cNetSocketBase::IOCtl |
( |
long |
lCmd, |
|
|
unsigned long * |
pnArgs |
|
) |
| const |
Like MFC CAsyncSocket IOCtl
- lCmd = FIONBIO = set/clear non-blocking i/o FIOASYNC = set/clear async i/o FIONREAD = read how much data is ready to read.
- Returns
- true = success
◆ isValidCheck()
bool GrayLib::cNetSocketBase::isValidCheck |
( |
| ) |
const |
|
virtualnoexcept |
< memory allocation and structure definitions are valid.
CObject memory allocation and structure definitions are valid.
NOT in MFC so use COBJECT_IsValidCheck to call.
- Note
- This can't be called in constructors and destructors of course !
Reimplemented from Gray::CObject.
◆ isValidSocket()
bool GrayLib::cNetSocketBase::isValidSocket |
( |
| ) |
const |
|
inlinenoexcept |
Is the socket created? Though it may not be connected. CreateSocket was called ?
◆ Listen()
bool GrayLib::cNetSocketBase::Listen |
( |
int |
iMaxBacklogConnections = SOMAXCONN | ) |
|
|
inline |
The listen function places a socket in a state in which it is listening for an incoming connection. NON blocking. SOCKETSTATE_Listening
◆ operator SOCKET()
GrayLib::cNetSocketBase::operator SOCKET |
( |
| ) |
const |
|
inlinenoexcept |
◆ Receive()
int GrayLib::cNetSocketBase::Receive |
( |
void * |
pBuffer, |
|
|
int |
nBufLen, |
|
|
int |
nFlags = 0 |
|
) |
| |
|
inline |
try to get data from the socket.
- nFlags = MSG_PEEK or MSG_OOB nBufLen = 0 = wait for data but don't read it.
- Returns
- length read, = 0 is gracefully closed. = SOCKET_ERROR (-1). errno=WSAEWOULDBLOCK. etc.
◆ Send()
int GrayLib::cNetSocketBase::Send |
( |
const void * |
pData, |
|
|
int |
iLen, |
|
|
int |
nFlags = 0 |
|
) |
| |
|
inline |
- flags = MSG_DONTROUTE, MSG_OOB, (linux MSG_NOSIGNAL)
- Returns
- length sent, else SOCKET_ERROR = failed. (<0) < iLen = Queue is full. blocked from writing for now.
- Note
- This can and DOES return less than iLen sent. (if non blocking mode) Send() has a limited Queue size and will fill quickly. Max send is typically packet size ~1200 ??
◆ SetSockOpt()
bool GrayLib::cNetSocketBase::SetSockOpt |
( |
int |
nOptionName, |
|
|
const void * |
optval, |
|
|
socklen_t |
optlen, |
|
|
int |
nLevel = SOL_SOCKET |
|
) |
| const |
nLevel = SOL_SOCKET or IPPROTO_TCP. (same as nProtocolType in socket() ??) nOptionName = SO_CONNECT_TIME, ...
◆ ShutDown()
Called as part of CloseFlush. before Close() _WIN32 = The shutdown function does NOT block regardless of the SO_LINGER setting on the socket.
◆ sm_iAllocSockets
ITERATE_t GrayLib::cNetSocketBase::sm_iAllocSockets = 0 |
|
static |
Count all open sockets. Watch out for WSADATA.iMaxSockets.
The documentation for this class was generated from the following files: