Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Socket Class Reference

#include <socket.h>

List of all members.

Public Methods

 Socket (SOCKET mSock, int size=4096)
 Socket (const Socket &r_sock)
virtual ~Socket ()
char Read ()
void Write (const char c)
void Write (const string &r_str)
void Write (const char *p_char)
void Write (const char *p_char, int len)
void Flush ()
SOCKET GetSocket ()
void Close ()

Private Methods

Socket & operator= (const Socket &r_sock)

Private Attributes

SOCKET mSock
 network socket

int mSize
 size of buffers

char * mpInBuffer
 the socket input buffer.

char * mpOutBuffer
 the socket output buffer.

char * mpRead
 pointer to the start of data in mpInBuffer.

char * mpEod
 pointer to the end of data in mpInBuffer.

char * mpWrite
 pointer to the next write position in mpOutBuffer.

char * mpStartWrite
 pointer to the data to start send in mpOutBuffer.


Detailed Description

The Socket class contains the minimum amount of attributes to reasonably maintain a socket connection with a client.

Note:
This was refactored out of the Connection class and implemented there as a composite member. It might have been made a superclass were it not for the all the functions we'd have to remap and/or override to keep exception and error handling safely within the Connection class.

Definition at line 53 of file socket.h.


Constructor & Destructor Documentation

Socket::Socket (  SOCKET    sock,
int    size = 4096
) 
 

The constructor for Socket

Parameters:
sock  The network socket to be associated with this Socket.
size  The size to allocate the both input and output buffers. Defaults to 4096.

Definition at line 24 of file socket.cpp.

References mpEod, mpInBuffer, mpOutBuffer, mpRead, mpStartWrite, mpWrite, and mSize.

Socket::Socket (  const Socket &    r_sock ) 
 

The copy constructor for Socket

Parameters:
r_sock  The Socket to copy.

Definition at line 36 of file socket.cpp.

References mpEod, mpInBuffer, mpOutBuffer, mpRead, mpStartWrite, mpWrite, and mSize.

Socket::~Socket (    )  [virtual]
 

Destructor for Socket

Definition at line 53 of file socket.cpp.

References mpInBuffer, and mpOutBuffer.


Member Function Documentation

void Socket::Close (    ) 
 

Close is called to close a Socket stream.

Definition at line 240 of file socket.cpp.

References mSock, and Read().

Referenced by Connection::Disconnect().

void Socket::Flush (    ) 
 

Flush sends the contents of the mOutBuffer to the socket stream. One must call flush to actually send the data in the buffer, although the buffer will automatically flush itself when it reaches mSize.

Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.

Definition at line 203 of file socket.cpp.

References mpOutBuffer, mpStartWrite, mpWrite, mSize, and mSock.

Referenced by Connection::HandleOutput(), and Write().

SOCKET Socket::GetSocket (    ) 
 

GetSocket gets the sockets value.

Returns :
the Socket's SOCKET value.

Definition at line 233 of file socket.cpp.

References mSock.

Referenced by Connection::GetSocket().

Socket& Socket::operator= (  const Socket &    r_sock )  [private]
 

char Socket::Read (    ) 
 

Read fetches a single character from the socket stream. We buffer our reads here.

Returns :
char A single character read from the socket stream.
Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.

Definition at line 69 of file socket.cpp.

References mpEod, mpInBuffer, mpRead, mSize, and mSock.

Referenced by Close(), and Connection::HandleInput().

void Socket::Write (  const char *    p_char,
int    len
) 
 

Write pushes the contents of a character array to the socket stream.

Parameters:
p_char  An array of characters to be pushed to the socket stream.
len  The number of characters to be pushed to the socket stream.
Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.
Note:
Any exceptions will be thrown from flush() in called character Write.
Todo:
We need a nice way to handle partially written character arrays here in the odd case that send blocks in the middle of this Write.

Definition at line 185 of file socket.cpp.

References Write().

void Socket::Write (  const char *    p_char ) 
 

Write pushes the contents of a null terminated character array to the socket stream.

Parameters:
p_char  A null terminated character array to be pushed to the socket stream.
Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.
Note:
Any exceptions will be thrown from flush() in called character Write.
Todo:
We need a nice way to handle partially written character arrays here in the odd case that send blocks in the middle of this Write.

Definition at line 160 of file socket.cpp.

References Write().

void Socket::Write (  const string &    r_str ) 
 

Write pushes the contents of a string to the socket stream.

Parameters:
r_str  A text string to be pushed to the socket stream.
Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.
Note:
Any exceptions will be thrown from flush() in called character Write.
Todo:
We need a nice way to handle partially written strings here in the odd case that send blocks in the middle of this Write.

Definition at line 133 of file socket.cpp.

References Write().

void Socket::Write (  const char    c ) 
 

Write pushes a single character to the socket stream. We buffer our writes here. One must call flush to actually send the data in the buffer, although the buffer will automatically flush itself when it reaches mSize.

Parameters:
c  A single character to be pushed to the socket stream.
Exceptions:
ShutdownException  Indicates that our connection has closed.
BlockingException  Normal condition that indicates the end of data
IOErrorException  This is a non-recoverable error that could indicate any number of conditions.
Note:
Any exceptions will be thrown from flush().

Definition at line 106 of file socket.cpp.

References Flush(), mpOutBuffer, mpWrite, and mSize.

Referenced by Connection::HandleOutput(), and Write().


Member Data Documentation

char* Socket::mpEod [private]
 

pointer to the end of data in mpInBuffer.

Definition at line 74 of file socket.h.

Referenced by Read(), and Socket().

char* Socket::mpInBuffer [private]
 

the socket input buffer.

Definition at line 71 of file socket.h.

Referenced by Read(), Socket(), and ~Socket().

char* Socket::mpOutBuffer [private]
 

the socket output buffer.

Definition at line 72 of file socket.h.

Referenced by Flush(), Socket(), Write(), and ~Socket().

char* Socket::mpRead [private]
 

pointer to the start of data in mpInBuffer.

Definition at line 73 of file socket.h.

Referenced by Read(), and Socket().

char* Socket::mpStartWrite [private]
 

pointer to the data to start send in mpOutBuffer.

Definition at line 76 of file socket.h.

Referenced by Flush(), and Socket().

char* Socket::mpWrite [private]
 

pointer to the next write position in mpOutBuffer.

Definition at line 75 of file socket.h.

Referenced by Flush(), Socket(), and Write().

int Socket::mSize [private]
 

size of buffers

Definition at line 70 of file socket.h.

Referenced by Flush(), Read(), Socket(), and Write().

SOCKET Socket::mSock [private]
 

network socket

Definition at line 69 of file socket.h.

Referenced by Close(), Flush(), GetSocket(), and Read().


The documentation for this class was generated from the following files:
Generated on Mon Mar 29 23:12:58 2004 for Paradigm by doxygen1.2.17