OW_NAMESPACE::Socket Class Reference

#include <OW_Socket.hpp>

Inheritance diagram for OW_NAMESPACE::Socket:

Inheritance graph
[legend]
Collaboration diagram for OW_NAMESPACE::Socket:

Collaboration graph
[legend]
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 (SocketFlags::ESSLFlag isSSL) OW_DEPRECATED
 Allocate a new 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.
std::istream & getInputStream ()
 Get an istream to read from the socket.
std::ostream & getOutputStream ()
 Get an ostream to write to the socket.
OW_DEPRECATED std::iostream & getIOStream ()
 Get an iostream to read/write from/to the socket.
Select_t getSelectObj () const
SocketHandle_t getfd ()
 Get the socket handle for the socket.
bool isConnected () const
 Get connected state.
SSL * getSSL () const
 get the SSL structure associated with the socket (if it is an SSL socket)
bool peerCertVerified () const
 did the peer certificate pass verification?

Static Public Member Functions

static void createShutDownMechanism ()
static void shutdownAllSockets ()
 Call this to shutdown all sockets.
static bool gotShutDown () OW_DEPRECATED
 Have the sockets been shutdown?
static void deleteShutDownMechanism ()
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 64 of file OW_Socket.hpp.


Member Typedef Documentation

typedef UnnamedPipeRef OW_NAMESPACE::Socket::ShutDownMechanism_t
 

Definition at line 251 of file OW_Socket.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::Socket::Socket  ) 
 

Construct a non-SSL Socket.

Definition at line 58 of file OW_Socket.cpp.

OW_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 63 of file OW_Socket.cpp.

References m_impl, and OW_THROW.

OW_NAMESPACE::Socket::Socket SocketFlags::ESSLFlag  isSSL  ) 
 

Allocate a new Socket.

Parameters:
isSSL is it an ssl socket?

Definition at line 80 of file OW_Socket.cpp.

References OW_NAMESPACE::SocketFlags::E_SSL, m_impl, and OW_THROW.

OW_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
isSSL is it an SSL socket?

Definition at line 96 of file OW_Socket.cpp.

References OW_NAMESPACE::SocketFlags::E_SSL, m_impl, and OW_THROW.

OW_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 is it an SSL socket?
Exceptions:
SocketException 

Definition at line 131 of file OW_Socket.cpp.

References OW_NAMESPACE::SocketFlags::E_SSL, m_impl, and OW_THROW.

OW_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
isSSL is it an SSL socket?

Definition at line 114 of file OW_Socket.cpp.

References m_impl, and OW_THROW.


Member Function Documentation

void OW_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 103 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkConnection(), OW_NAMESPACE::HTTPClient::getLocalAddress(), and OW_NAMESPACE::HTTPClient::getPeerAddress().

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

Definition at line 174 of file OW_Socket.cpp.

References OW_NAMESPACE::b_gotShutDown, OW_NAMESPACE::UnnamedPipe::createUnnamedPipe(), OW_NAMESPACE::UnnamedPipe::E_NONBLOCKING, OW_ASSERT, s_shutDownMechanism, and OW_NAMESPACE::shutdownMutex.

Referenced by OW_NAMESPACE::CIMOMEnvironment::startServices().

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

Definition at line 192 of file OW_Socket.cpp.

References s_shutDownMechanism, and OW_NAMESPACE::shutdownMutex.

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

Disconnect the (presumably) open connection.

Definition at line 108 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkConnection(), OW_NAMESPACE::HTTPClient::close(), OW_NAMESPACE::HTTPSvrConnection::doCooperativeCancel(), and OW_NAMESPACE::HTTPSvrConnection::~HTTPSvrConnection().

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

Get the connect timeout.

Returns:
The number of seconds of the connect timeout

Definition at line 140 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::getConnectTimeout().

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

Get the socket handle for the socket.

Returns:
the socket handle

Definition at line 227 of file OW_Socket.hpp.

std::istream& OW_NAMESPACE::Socket::getInputStream  )  [inline]
 

Get an istream to read from the socket.

Returns:
a istream& which can be used for socket input
Exceptions:
SocketException 

Definition at line 203 of file OW_Socket.hpp.

OW_DEPRECATED std::iostream& OW_NAMESPACE::Socket::getIOStream  )  [inline]
 

Get an iostream to read/write from/to the socket.

Returns:
an iostream& which can be used for socket input and output.
Exceptions:
SocketException 

Definition at line 217 of file OW_Socket.hpp.

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

Get the local address associated with the socket connection.

Returns:
an SocketAddress representing the local machine

Definition at line 192 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPServerSelectableCallback::doSelected().

std::ostream& OW_NAMESPACE::Socket::getOutputStream  )  [inline]
 

Get an ostream to write to the socket.

Returns:
an ostream& which can be used for socket output
Exceptions:
SocketException 

Definition at line 210 of file OW_Socket.hpp.

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

Get the peer address associated with the socket connection.

Returns:
an SocketAddress representing the peer machine

Definition at line 197 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPServerSelectableCallback::doSelected(), and OW_NAMESPACE::HTTPSvrConnection::run().

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

Get the receive timeout.

Returns:
The number of seconds of the receive timeout

Definition at line 120 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkResponse(), and OW_NAMESPACE::HTTPClient::getReceiveTimeout().

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

Returns:
The Select_t associated with this sockect.

Implements OW_NAMESPACE::SelectableIFC.

Definition at line 222 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPSvrConnection::run().

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

Get the send timeout.

Returns:
The number of seconds of the send timeout

Definition at line 130 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::getSendTimeout().

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

Definition at line 254 of file OW_Socket.hpp.

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

SSL * OW_NAMESPACE::Socket::getSSL  )  const
 

get the SSL structure associated with the socket (if it is an SSL socket)

Returns:
a pointer to the SSL structure

Definition at line 213 of file OW_Socket.cpp.

References OW_NAMESPACE::IntrusiveReference< T >::cast_to(), and m_impl.

bool OW_NAMESPACE::Socket::gotShutDown  )  [static]
 

Have the sockets been shutdown?

Returns:
true if the sockets have been shutdown

Definition at line 206 of file OW_Socket.cpp.

References OW_NAMESPACE::b_gotShutDown, and OW_NAMESPACE::shutdownMutex.

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

Get connected state.

Definition at line 232 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkAndExamineStatusLine(), OW_NAMESPACE::HTTPClient::checkConnection(), OW_NAMESPACE::HTTPClient::getLocalAddress(), and OW_NAMESPACE::HTTPClient::getPeerAddress().

bool OW_NAMESPACE::Socket::peerCertVerified  )  const
 

did the peer certificate pass verification?

Returns:
true if peer cert verified.

Definition at line 225 of file OW_Socket.cpp.

References OW_NAMESPACE::IntrusiveReference< T >::cast_to(), and m_impl.

int OW_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 OW_NAMESPACE::IOIFC.

Definition at line 169 of file OW_Socket.hpp.

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

Has the receive timeout expired?

Returns:
true if the receive timeout has expired.

Definition at line 150 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkResponse(), and OW_NAMESPACE::HTTPSvrConnection::sendError().

void OW_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 135 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::setConnectTimeout().

void OW_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 115 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::setReceiveTimeout().

void OW_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 125 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::setSendTimeout().

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

Set all timeouts (send, receive, connect).

Parameters:
seconds the number of seconds for the timeouts

Definition at line 145 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::setTimeouts().

void OW_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 151 of file OW_Socket.cpp.

References OW_NAMESPACE::b_gotShutDown, OW_ASSERT, OW_THROW_ERRNO_MSG, s_shutDownMechanism, and OW_NAMESPACE::shutdownMutex.

bool OW_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 177 of file OW_Socket.hpp.

Referenced by OW_NAMESPACE::HTTPClient::checkAndExamineStatusLine().

bool OW_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 185 of file OW_Socket.hpp.

int OW_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 OW_NAMESPACE::IOIFC.

Definition at line 159 of file OW_Socket.hpp.


Friends And Related Function Documentation

friend class ServerSocketImpl [friend]
 

Definition at line 297 of file OW_Socket.hpp.


Member Data Documentation

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

Definition at line 110 of file OW_Socket.hpp.

SocketBaseImplRef OW_NAMESPACE::Socket::m_impl [private]
 

Definition at line 289 of file OW_Socket.hpp.

Referenced by getSSL(), peerCertVerified(), and Socket().

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

Definition at line 295 of file OW_Socket.hpp.

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


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:14:54 2006 for openwbem by  doxygen 1.4.6