BLOCXX_NAMESPACE::Socket Class Reference

#include <Socket.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::Socket:

BLOCXX_NAMESPACE::SelectableIFC BLOCXX_NAMESPACE::IOIFC BLOCXX_NAMESPACE::IntrusiveCountableBase List of all members.

Public Types

typedef UnnamedPipeRef ShutDownMechanism_t

Public Member Functions

 Socket ()
 Construct a non-SSL Socket.
 Socket (const SSLClientCtxRef &sslCtx)
 Construct a Socket.
 Socket (SocketHandle_t fd, SocketAddress::AddressType addrType, SocketFlags::ESSLFlag isSSL=SocketFlags::E_NOT_SSL)
 TODO: Make a replacement for this function so it can be deprecated.
 Socket (const SocketAddress &addr, SocketFlags::ESSLFlag isSSL=SocketFlags::E_NOT_SSL)
 TODO: Make a replacement for this function so it can be deprecated.
void connect (const SocketAddress &addr)
 Connect to a peer node.
void disconnect ()
 Disconnect the (presumably) open connection.
void setReceiveTimeout (int seconds)
 Set the receive timeout on the socket.
int getReceiveTimeout () const
 Get the receive timeout.
void setSendTimeout (int seconds)
 Set the send timeout on the socket.
int getSendTimeout () const
 Get the send timeout.
void setConnectTimeout (int seconds)
 Set the connect timeout on the socket.
int getConnectTimeout () const
 Get the connect timeout.
void setTimeouts (int seconds)
 Set all timeouts (send, receive, connect).
bool receiveTimeOutExpired () const
 Has the receive timeout expired?
int write (const void *dataOut, int dataOutLen, bool errorAsException=false)
 Write some data to the socket.
int read (void *dataIn, int dataInLen, bool errorAsException=false)
 Read from the socket.
bool waitForInput (int timeOutSecs=INFINITE_TIMEOUT)
 Wait for input on the socket for a specified length of time.
bool waitForOutput (int timeOutSecs=INFINITE_TIMEOUT)
 Wait for output on the socket for a specified length of time.
SocketAddress getLocalAddress () const
 Get the local address associated with the socket connection.
SocketAddress getPeerAddress () const
 Get the peer address associated with the socket connection.
Select_t getSelectObj () const
SocketHandle_t getfd ()
 Get the socket handle for the socket.
bool isConnected () const
 Get connected state.

Static Public Member Functions

static void createShutDownMechanism ()
static void shutdownAllSockets ()
 Call this to shutdown all sockets.
static void deleteShutDownMechanism ()
 Have the sockets been shutdown?
static ShutDownMechanism_t getShutDownMechanism ()

Static Public Attributes

static const int INFINITE_TIMEOUT = -1

Private Member Functions

 Socket (SocketHandle_t fd, SocketAddress::AddressType addrType, const SSLServerCtxRef &sslCtx)
 Allocate a new Socket based on an existing handle.

Private Attributes

SocketBaseImplRef m_impl

Static Private Attributes

static ShutDownMechanism_t s_shutDownMechanism = 0

Friends

class ServerSocketImpl

Detailed Description

Definition at line 66 of file Socket.hpp.


Member Typedef Documentation

typedef UnnamedPipeRef BLOCXX_NAMESPACE::Socket::ShutDownMechanism_t
 

Definition at line 227 of file Socket.hpp.


Constructor & Destructor Documentation

BLOCXX_NAMESPACE::Socket::Socket  ) 
 

Construct a non-SSL Socket.

Definition at line 61 of file Socket.cpp.

BLOCXX_NAMESPACE::Socket::Socket const SSLClientCtxRef sslCtx  ) 
 

Construct a Socket.

Parameters:
sslCtx The SSL client context. If null, the socket will not use SSL.

Definition at line 66 of file Socket.cpp.

References BLOCXX_THROW, and m_impl.

BLOCXX_NAMESPACE::Socket::Socket SocketHandle_t  fd,
SocketAddress::AddressType  addrType,
SocketFlags::ESSLFlag  isSSL = SocketFlags::E_NOT_SSL
 

TODO: Make a replacement for this function so it can be deprecated.

Allocate a new Socket based on an existing handle. This is used by ServerSocket::accept()

Parameters:
fd a handle to the existing socket
addrType the address type of the socket
isSSL is it an SSL socket?

Definition at line 83 of file Socket.cpp.

References BLOCXX_THROW, BLOCXX_NAMESPACE::SocketFlags::E_SSL, and m_impl.

BLOCXX_NAMESPACE::Socket::Socket const SocketAddress addr,
SocketFlags::ESSLFlag  isSSL = SocketFlags::E_NOT_SSL
 

TODO: Make a replacement for this function so it can be deprecated.

Allocate a new Socket and connect it to a peer machine

Parameters:
addr the address of the peer machine
isSSL is it an SSL socket?
Exceptions:
SocketException 

Definition at line 118 of file Socket.cpp.

References BLOCXX_THROW, BLOCXX_NAMESPACE::SocketFlags::E_SSL, and m_impl.

BLOCXX_NAMESPACE::Socket::Socket SocketHandle_t  fd,
SocketAddress::AddressType  addrType,
const SSLServerCtxRef sslCtx
[private]
 

Allocate a new Socket based on an existing handle.

This is used by ServerSocket::accept()

Parameters:
fd a handle to the existing socket
addrType the address type of the socket
sslCtx a SSL server context reference

Definition at line 101 of file Socket.cpp.

References BLOCXX_THROW, and m_impl.


Member Function Documentation

void BLOCXX_NAMESPACE::Socket::connect const SocketAddress addr  )  [inline]
 

Connect to a peer node.

Parameters:
addr The address of the machine to connect to.
Exceptions:
SocketException 

Definition at line 101 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::createShutDownMechanism  )  [static]
 

Definition at line 161 of file Socket.cpp.

References BLOCXX_NAMESPACE::b_gotShutDown, BLOCXX_ASSERT, BLOCXX_NAMESPACE::UnnamedPipe::createUnnamedPipe(), BLOCXX_NAMESPACE::UnnamedPipe::E_NONBLOCKING, s_shutDownMechanism, and BLOCXX_NAMESPACE::shutdownMutex.

void BLOCXX_NAMESPACE::Socket::deleteShutDownMechanism  )  [static]
 

Have the sockets been shutdown?

Returns:
true if the sockets have been shutdown

Definition at line 179 of file Socket.cpp.

References s_shutDownMechanism, and BLOCXX_NAMESPACE::shutdownMutex.

void BLOCXX_NAMESPACE::Socket::disconnect  )  [inline]
 

Disconnect the (presumably) open connection.

Definition at line 106 of file Socket.hpp.

int BLOCXX_NAMESPACE::Socket::getConnectTimeout  )  const [inline]
 

Get the connect timeout.

Returns:
The number of seconds of the connect timeout

Definition at line 138 of file Socket.hpp.

SocketHandle_t BLOCXX_NAMESPACE::Socket::getfd  )  [inline]
 

Get the socket handle for the socket.

Returns:
the socket handle

Definition at line 204 of file Socket.hpp.

SocketAddress BLOCXX_NAMESPACE::Socket::getLocalAddress  )  const [inline]
 

Get the local address associated with the socket connection.

Returns:
an SocketAddress representing the local machine

Definition at line 190 of file Socket.hpp.

SocketAddress BLOCXX_NAMESPACE::Socket::getPeerAddress  )  const [inline]
 

Get the peer address associated with the socket connection.

Returns:
an SocketAddress representing the peer machine

Definition at line 195 of file Socket.hpp.

int BLOCXX_NAMESPACE::Socket::getReceiveTimeout  )  const [inline]
 

Get the receive timeout.

Returns:
The number of seconds of the receive timeout

Definition at line 118 of file Socket.hpp.

Select_t BLOCXX_NAMESPACE::Socket::getSelectObj  )  const [inline, virtual]
 

Returns:
The Select_t associated with this sockect.

Implements BLOCXX_NAMESPACE::SelectableIFC.

Definition at line 199 of file Socket.hpp.

int BLOCXX_NAMESPACE::Socket::getSendTimeout  )  const [inline]
 

Get the send timeout.

Returns:
The number of seconds of the send timeout

Definition at line 128 of file Socket.hpp.

static ShutDownMechanism_t BLOCXX_NAMESPACE::Socket::getShutDownMechanism  )  [inline, static]
 

Definition at line 230 of file Socket.hpp.

Referenced by BLOCXX_NAMESPACE::SocketUtils::waitForIO().

bool BLOCXX_NAMESPACE::Socket::isConnected  )  const [inline]
 

Get connected state.

Definition at line 209 of file Socket.hpp.

int BLOCXX_NAMESPACE::Socket::read void *  dataIn,
int  dataInLen,
bool  errorAsException = false
[inline, virtual]
 

Read from the socket.

Parameters:
dataIn a pointer to a buffer where data should be copied to
dataInLen the number of bytes to read.
errorAsException true if errors should throw exceptions.
Returns:
the number of bytes read.
Exceptions:
SocketException 

Implements BLOCXX_NAMESPACE::IOIFC.

Definition at line 167 of file Socket.hpp.

bool BLOCXX_NAMESPACE::Socket::receiveTimeOutExpired  )  const [inline]
 

Has the receive timeout expired?

Returns:
true if the receive timeout has expired.

Definition at line 148 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::setConnectTimeout int  seconds  )  [inline]
 

Set the connect timeout on the socket.

Parameters:
seconds the number of seconds for the connect timeout

Definition at line 133 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::setReceiveTimeout int  seconds  )  [inline]
 

Set the receive timeout on the socket.

Parameters:
seconds the number of seconds for the receive timeout

Definition at line 113 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::setSendTimeout int  seconds  )  [inline]
 

Set the send timeout on the socket.

Parameters:
seconds the number of seconds for the send timeout

Definition at line 123 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::setTimeouts int  seconds  )  [inline]
 

Set all timeouts (send, receive, connect).

Parameters:
seconds the number of seconds for the timeouts

Definition at line 143 of file Socket.hpp.

void BLOCXX_NAMESPACE::Socket::shutdownAllSockets  )  [static]
 

Call this to shutdown all sockets.

This is usefull when the CIMOM is shutting down. We want any outstanding connections to close immediately.

Definition at line 138 of file Socket.cpp.

References BLOCXX_NAMESPACE::b_gotShutDown, BLOCXX_ASSERT, BLOCXX_THROW_ERRNO_MSG, s_shutDownMechanism, and BLOCXX_NAMESPACE::shutdownMutex.

bool BLOCXX_NAMESPACE::Socket::waitForInput int  timeOutSecs = INFINITE_TIMEOUT  )  [inline]
 

Wait for input on the socket for a specified length of time.

Parameters:
timeOutSecs the number of seconds to wait.
Returns:
true if the timeout expired
Exceptions:
SocketException 

Definition at line 175 of file Socket.hpp.

bool BLOCXX_NAMESPACE::Socket::waitForOutput int  timeOutSecs = INFINITE_TIMEOUT  )  [inline]
 

Wait for output on the socket for a specified length of time.

Parameters:
timeOutSecs the number of seconds to wait.
Returns:
true if the timeout expired
Exceptions:
SocketException 

Definition at line 183 of file Socket.hpp.

int BLOCXX_NAMESPACE::Socket::write const void *  dataOut,
int  dataOutLen,
bool  errorAsException = false
[inline, virtual]
 

Write some data to the socket.

Parameters:
dataOut a pointer to the memory to be written to the socket.
dataOutLen the length of the data to be written
errorAsException true if errors should throw exceptions.
Returns:
the number of bytes written.
Exceptions:
SocketException 

Implements BLOCXX_NAMESPACE::IOIFC.

Definition at line 157 of file Socket.hpp.


Friends And Related Function Documentation

friend class ServerSocketImpl [friend]
 

Definition at line 274 of file Socket.hpp.


Member Data Documentation

const int BLOCXX_NAMESPACE::Socket::INFINITE_TIMEOUT = -1 [static]
 

Definition at line 108 of file Socket.hpp.

SocketBaseImplRef BLOCXX_NAMESPACE::Socket::m_impl [private]
 

Definition at line 266 of file Socket.hpp.

Referenced by Socket().

Socket::ShutDownMechanism_t BLOCXX_NAMESPACE::Socket::s_shutDownMechanism = 0 [static, private]
 

Definition at line 272 of file Socket.hpp.

Referenced by createShutDownMechanism(), deleteShutDownMechanism(), and shutdownAllSockets().


The documentation for this class was generated from the following files:
Generated on Fri Jun 16 15:39:11 2006 for blocxx by  doxygen 1.4.6