C++ common classes
General purpose classes for use across projects (Apache license)
CBaseSocket Class Reference

Base socket class implements low level Berkley socket functionality. More...

#include <CBaseSocket.h>

Inheritance diagram for CBaseSocket:
CConnectionSocket CPConnection CPServer CServerSocket CUDPSocket CClientSocket CPClient CHTTPClient

List of all members.

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

Detailed Description

Base socket class implements low level Berkley socket functionality.

Definition at line 39 of file CBaseSocket.h.


Constructor & Destructor Documentation

constructor

Definition at line 32 of file CBaseSocket.cpp.

Definition at line 39 of file CBaseSocket.cpp.


Member Function Documentation

Close socket.

Reimplemented in CUDPSocket.

Definition at line 207 of file CBaseSocket.cpp.

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

Parameters:
typeAddress family. Only tested with AF_INET.
protocolStream or datagram (SOCK_STREAM or SOCK_DRAM)
nPortUsually 0 for inet sockets
lpAddrPort
bReuseAddress. For inet in the standard xxx.xxx.xxx.xxx format, for AF_UNIX the path
bBindAllow reuse of this socket
iLingerDefault 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.


Member Data Documentation

Definition at line 76 of file CBaseSocket.h.

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.

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines