Socket Class Reference

#include <Socket.h>

Inheritance diagram for Socket:

ConnectableSocket TcpConnectionServer TcpSocket List of all members.

Public Types

enum  SocketShutdownMode { ShutdownReceive = 0x00, ShutdownSend = 0x01, ShutdownBoth = 0x02 }

Public Member Functions

virtual ~Socket ()
bool operator== (const Socket &socket) const throw ()
bool operator< (const Socket &socket) const throw ()
std::ostream & operator<< (std::ostream &stream) const
bool isOpen () const throw ()
void close ()
bool isAutoClosing () const throw ()
void setToAutoClose (bool autoClose) throw ()
void bind (const SocketAddress &address)
void shutdownSocketSends ()
void shutdownSocketReceives ()
void shutdown ()
void shutdown (SocketShutdownMode code)
int getSocketType () const
SocketAddress getSocketAddress () const
 operator SOCKET () const throw ()
SOCKET getDescriptor () const throw ()
void setDescriptor (SOCKET socketHandle) throw ()
int getReceivingBufferSize () const
void setReceivingBufferSize (int size)
int getSendingBufferSize () const
void setSendingBufferSize (int newBufferSize)
int getAndClearErrorStatus ()
bool getLingerInformation (int &seconds) const
void setLingerInformation (bool flag, int seconds)
bool getRouting () const
void setRouting (bool flag)
bool canLocalAddressesBeReused () const
void setReuseLocalAddresses (bool flag)

Protected Member Functions

 Socket (SOCKET descriptor)
 Socket (int type, int domain, int protocol=0)
void reset (int type, int domain, int protocol=0)
void bind (sockaddr *address, int size)
void name (sockaddr *address, int &size) const
int getOption (int code) const
void getOption (int code, void *storage, int &size) const
void setOption (int code, int value)
void setOption (int code, void *storage, int size)
bool getBoolOption (int code) const
void setBoolOption (int code, bool flag)

Protected Attributes

SOCKET socketHandle
bool autoClosing
short flags_

Detailed Description

enum SocketOptions { IpAddMembership, // Add an IP group membership. IpDropMembership. // Drop an IP group membership. IpMulticastLoop, // IP Multicast loopback. IpMulticastTTL, // IP multicast time to live. OptionLevelIP, // Indicates socket options apply to IP sockets. OptionLevelTCP, // Indicates socket options apply to TCP sockets. SoAcceptConn, // Socket is listening. SoBroadcast, // Permit sending broadcast messages on the socket. SoDebug, // Record debugging information. SoDontLingee, // Does not block waiting for unsent data to be sent. SoDontRoute, // Do not route, send directly to interface addresses. SoError, // Get error status and clear. SoExclusiveAddrUse, // Enables a socket to be bound for exclusive access. SoKeepalive, // Send keep-alives. SoLinger, // Linger on close if unsent data is present. SolSocket, // Indicates socket options apply to the socket itself. SoMaxConn, // Maximum queue length that can be specified by Listen. SoOOBInline, // Receives out-of-band data in the normal data stream. SoRcvBuf, // Specifies the total per-socket buffer space reserved for receives. This is unrelated to the maximum message size or the size of a TCP window. SoRcvLowat, // Receive low water mark. SoRcvTimeo, // Receive timeout. SoReuseAddr, // Allows the socket to be bound to an address that is already in use. SoSndBuf, // Specifies the total per-socket buffer space reserved for sends. This is unrelated to the maximum message size or the size of a TCP window. SoSndLowat, // Send low water mark. SoSndTimeo, // Send timeout. SoType, // Get socket type. SoUseLoopback, // Bypass hardware when possible. TcpBSDUrgent, // [To be supplied.] TcpNodelay // Disables the Nagle algorithm for send coalescing. };

Definition at line 75 of file Socket.h.


Member Enumeration Documentation

enum Socket::SocketShutdownMode
 

Enumerator:
ShutdownReceive 
ShutdownSend 
ShutdownBoth 

Definition at line 79 of file Socket.h.


Constructor & Destructor Documentation

Socket::~Socket  )  [virtual]
 

Definition at line 169 of file Socket.cpp.

References close(), and isAutoClosing().

Socket::Socket SOCKET  descriptor  )  [protected]
 

Definition at line 64 of file Socket.cpp.

Socket::Socket int  type,
int  domain,
int  protocol = 0
[protected]
 

Definition at line 157 of file Socket.cpp.

References setDescriptor(), and SOCKET_CALL_3.


Member Function Documentation

void Socket::bind sockaddr *  address,
int  size
[protected]
 

Definition at line 207 of file Socket.cpp.

References bind(), getDescriptor(), and SOCKET_CALL_3.

void Socket::bind const SocketAddress address  ) 
 

Definition at line 149 of file Socket.cpp.

Referenced by bind(), TcpConnectionServer::TcpConnectionServer(), and TcpSocket::TcpSocket().

bool Socket::canLocalAddressesBeReused  )  const
 

Definition at line 125 of file Socket.cpp.

References getBoolOption().

void Socket::close  ) 
 

Definition at line 288 of file Socket.cpp.

References closesocket, and socketHandle.

Referenced by TcpConnectionServer::accept(), processSocket(), reset(), SOAPonHTTP::send(), and ~Socket().

int Socket::getAndClearErrorStatus  ) 
 

Definition at line 106 of file Socket.cpp.

References getOption().

bool Socket::getBoolOption int  code  )  const [protected]
 

Definition at line 82 of file Socket.cpp.

References getOption().

Referenced by canLocalAddressesBeReused(), getRouting(), and TcpSocket::keepAlive().

SOCKET Socket::getDescriptor  )  const throw ()
 

Definition at line 40 of file Socket.cpp.

References socketHandle.

Referenced by TcpConnectionServer::accept(), bind(), ConnectableSocket::connectTo(), getOption(), isOpen(), TcpConnectionServer::listen(), name(), operator<<(), ConnectableSocket::operator<<(), ConnectableSocket::peerAddress(), ConnectableSocket::receiveFrom(), setOption(), and shutdown().

bool Socket::getLingerInformation int &  seconds  )  const
 

Definition at line 224 of file Socket.cpp.

References getOption().

void Socket::getOption int  code,
void *  storage,
int &  size
const [protected]
 

Definition at line 311 of file Socket.cpp.

References getDescriptor(), and SOCKET_CALL_5.

int Socket::getOption int  code  )  const [protected]
 

Definition at line 214 of file Socket.cpp.

Referenced by getAndClearErrorStatus(), getBoolOption(), getLingerInformation(), getReceivingBufferSize(), getSendingBufferSize(), and getSocketType().

int Socket::getReceivingBufferSize  )  const
 

Definition at line 181 of file Socket.cpp.

References getOption().

Referenced by processSocket().

bool Socket::getRouting  )  const
 

Definition at line 113 of file Socket.cpp.

References getBoolOption().

int Socket::getSendingBufferSize  )  const
 

Definition at line 194 of file Socket.cpp.

References getOption().

SocketAddress Socket::getSocketAddress  )  const
 

Definition at line 244 of file Socket.cpp.

References name().

int Socket::getSocketType  )  const
 

Definition at line 100 of file Socket.cpp.

References getOption().

bool Socket::isAutoClosing  )  const throw ()
 

Definition at line 137 of file Socket.cpp.

References autoClosing.

Referenced by ~Socket().

bool Socket::isOpen  )  const throw ()
 

Definition at line 58 of file Socket.cpp.

References getDescriptor().

Referenced by ConnectableSocket::isOk(), operator<<(), and ConnectableSocket::operator<<().

void Socket::name sockaddr *  address,
int &  size
const [protected]
 

Definition at line 325 of file Socket.cpp.

References getDescriptor(), and SOCKET_CALL_3.

Referenced by getSocketAddress().

Socket::operator SOCKET  )  const throw ()
 

Definition at line 75 of file Socket.cpp.

References socketHandle.

bool Socket::operator< const Socket socket  )  const throw ()
 

Definition at line 52 of file Socket.cpp.

std::ostream & Socket::operator<< std::ostream &  stream  )  const
 

TcpServer Socket library

Copyright (c) 2000 Jasen Plietz All rights reserved.

No warranties are extended. Use at your own risk.

To contact the author with suggestions or comments, use Jasen@plietz.net

Reimplemented in ConnectableSocket.

Definition at line 28 of file Socket.cpp.

References getDescriptor(), and isOpen().

bool Socket::operator== const Socket socket  )  const throw ()
 

Definition at line 46 of file Socket.cpp.

void Socket::reset int  type,
int  domain,
int  protocol = 0
[protected]
 

Definition at line 295 of file Socket.cpp.

References close(), setDescriptor(), and SOCKET_CALL_3.

Referenced by TcpSocket::reset().

void Socket::setBoolOption int  code,
bool  flag
[protected]
 

Definition at line 94 of file Socket.cpp.

References setOption().

Referenced by TcpSocket::setKeepAlives(), setReuseLocalAddresses(), and setRouting().

void Socket::setDescriptor SOCKET  socketHandle  )  throw ()
 

Definition at line 69 of file Socket.cpp.

Referenced by TcpConnectionServer::accept(), reset(), and Socket().

void Socket::setLingerInformation bool  flag,
int  seconds
 

Definition at line 234 of file Socket.cpp.

References setOption().

void Socket::setOption int  code,
void *  storage,
int  size
[protected]
 

Definition at line 280 of file Socket.cpp.

References getDescriptor(), and SOCKET_CALL_5.

void Socket::setOption int  code,
int  value
[protected]
 

Definition at line 88 of file Socket.cpp.

Referenced by setBoolOption(), setLingerInformation(), setReceivingBufferSize(), and setSendingBufferSize().

void Socket::setReceivingBufferSize int  size  ) 
 

Definition at line 188 of file Socket.cpp.

References setOption().

void Socket::setReuseLocalAddresses bool  flag  ) 
 

Definition at line 131 of file Socket.cpp.

References setBoolOption().

Referenced by TcpConnectionServer::TcpConnectionServer().

void Socket::setRouting bool  flag  ) 
 

Definition at line 119 of file Socket.cpp.

References setBoolOption().

void Socket::setSendingBufferSize int  newBufferSize  ) 
 

Definition at line 201 of file Socket.cpp.

References setOption().

void Socket::setToAutoClose bool  autoClose  )  throw ()
 

Definition at line 143 of file Socket.cpp.

void Socket::shutdown SocketShutdownMode  code  ) 
 

Definition at line 272 of file Socket.cpp.

References getDescriptor(), shutdown(), and SOCKET_CALL_2.

void Socket::shutdown  ) 
 

Definition at line 266 of file Socket.cpp.

References ShutdownBoth.

Referenced by shutdown(), shutdownSocketReceives(), and shutdownSocketSends().

void Socket::shutdownSocketReceives  ) 
 

Definition at line 254 of file Socket.cpp.

References shutdown(), and ShutdownReceive.

void Socket::shutdownSocketSends  ) 
 

Definition at line 260 of file Socket.cpp.

References shutdown(), and ShutdownSend.


Member Data Documentation

bool Socket::autoClosing [protected]
 

Definition at line 197 of file Socket.h.

Referenced by isAutoClosing().

short Socket::flags_ [protected]
 

Definition at line 200 of file Socket.h.

Referenced by ConnectableSocket::clear(), ConnectableSocket::eventOnEof(), ConnectableSocket::getFlags(), ConnectableSocket::isEof(), ConnectableSocket::isOk(), ConnectableSocket::read(), ConnectableSocket::receiveFrom(), and ConnectableSocket::write().

SOCKET Socket::socketHandle [protected]
 

Definition at line 194 of file Socket.h.

Referenced by close(), getDescriptor(), operator SOCKET(), ConnectableSocket::read(), and ConnectableSocket::write().


The documentation for this class was generated from the following files:
Generated on Tue Mar 28 09:10:16 2006 for Simple SOAP by  doxygen 1.4.6