C++ common classes
General purpose classes for use across projects (Apache license)
|
Base socket class implements low level Berkley socket functionality. More...
#include <CBaseSocket.h>
Public Member Functions | |
CBaseSocket () | |
constructor | |
virtual | ~CBaseSocket () |
virtual BOOL | Create (int af, int type, int protocol, UINT nPort=0, LPCSTR lpAddr=NULL, BOOL bReuse=FALSE, BOOL bBind=TRUE, int iLinger=-1, BOOL bNoTcpDelay=FALSE) |
methods | |
virtual BOOL | SetBlockingMode (BOOL bBlock=TRUE) |
Make this a blocking socket. | |
virtual void | CloseSocket () |
Close socket. | |
virtual struct sockaddr_in * | GetSocketName () |
Return a socket address structure with info currently bound to the socket. | |
virtual const char * | GetSocketAddressAsString () |
Return the socket address as a string. | |
virtual int | GetCreateError () |
Return the last create error. | |
virtual int | GetSocketType () |
Get socket type. | |
Protected Member Functions | |
virtual void | UnprotectedCloseSocket () |
Unprotected close socket - called by CloseSocket. | |
Protected Attributes | |
SOCKET | sSocket |
CXPlatCriticalSection | cCriticalSocket |
BOOL | bBlocking |
struct sockaddr_in | sTAddr |
int | iCreateError |
string | sUnixPath |
int | iAF |
Base socket class implements low level Berkley socket functionality.
Definition at line 39 of file CBaseSocket.h.
constructor
Definition at line 32 of file CBaseSocket.cpp.
CBaseSocket::~CBaseSocket | ( | ) | [virtual] |
Definition at line 39 of file CBaseSocket.cpp.
void CBaseSocket::CloseSocket | ( | ) | [virtual] |
BOOL CBaseSocket::Create | ( | int | af, |
int | type, | ||
int | protocol, | ||
UINT | nPort = 0 , |
||
LPCSTR | lpAddr = NULL , |
||
BOOL | bReuse = FALSE , |
||
BOOL | bBind = TRUE , |
||
int | iLinger = -1 , |
||
BOOL | bNoTcpDelay = FALSE |
||
) | [virtual] |
methods
type | Address family. Only tested with AF_INET. |
protocol | Stream or datagram (SOCK_STREAM or SOCK_DRAM) |
nPort | Usually 0 for inet sockets |
lpAddr | Port |
bReuse | Address. For inet in the standard xxx.xxx.xxx.xxx format, for AF_UNIX the path |
bBind | Allow reuse of this socket |
iLinger | Default to bind the socket. Not needed if this is the result of an ::accept |
bNoTcpDelay | -1 = system default, 0 = DONT_LINGER, else the timeout |
Definition at line 52 of file CBaseSocket.cpp.
int CBaseSocket::GetCreateError | ( | ) | [virtual] |
Return the last create error.
Definition at line 167 of file CBaseSocket.cpp.
const char * CBaseSocket::GetSocketAddressAsString | ( | ) | [virtual] |
Return the socket address as a string.
Definition at line 271 of file CBaseSocket.cpp.
struct sockaddr_in * CBaseSocket::GetSocketName | ( | ) | [read, virtual] |
Return a socket address structure with info currently bound to the socket.
Definition at line 247 of file CBaseSocket.cpp.
int CBaseSocket::GetSocketType | ( | ) | [virtual] |
Get socket type.
Definition at line 175 of file CBaseSocket.cpp.
BOOL CBaseSocket::SetBlockingMode | ( | BOOL | bBlock = TRUE | ) | [virtual] |
Make this a blocking socket.
FALSE = system default, TRUE = disable Nagle algorithm and send partial data
Definition at line 183 of file CBaseSocket.cpp.
void CBaseSocket::UnprotectedCloseSocket | ( | ) | [protected, virtual] |
Unprotected close socket - called by CloseSocket.
Reimplemented in CPConnection.
Definition at line 221 of file CBaseSocket.cpp.
BOOL CBaseSocket::bBlocking [protected] |
Definition at line 76 of file CBaseSocket.h.
CXPlatCriticalSection CBaseSocket::cCriticalSocket [protected] |
Definition at line 75 of file CBaseSocket.h.
int CBaseSocket::iAF [protected] |
Definition at line 80 of file CBaseSocket.h.
int CBaseSocket::iCreateError [protected] |
Definition at line 78 of file CBaseSocket.h.
SOCKET CBaseSocket::sSocket [protected] |
Definition at line 74 of file CBaseSocket.h.
struct sockaddr_in CBaseSocket::sTAddr [protected] |
Definition at line 77 of file CBaseSocket.h.
string CBaseSocket::sUnixPath [protected] |
Definition at line 79 of file CBaseSocket.h.