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

lfc::Socket Class Reference

medium level socket type. allows easy communication. More...

Inheritance diagram for lfc::Socket::

lfc::Object lfc::_Input< char > lfc::_Output< char > lfc::_Named lfc::_Server lfc::_Server List of all members.

Public Types

enum  State { stOpen, stClosed }
enum  Protocol { pfINET = pal::sockets::pfINET, pfUNIX = pal::sockets::pfUNIX, pfIPX = pal::sockets::pfIPX }
 available communications protocols. More...

enum  SocketType { stStream = pal::sockets::stSTREAM, stDatagram = pal::sockets::stDGRAM }
 connection oriented or connectionless. More...

enum  Flags { flagPeek = pal::sockets::flagPEEK, flagOOB = pal::sockets::flagOOB }
 peek and Out of Band flags. More...


Public Methods

 Socket () throw ()
 creates a Socket but doesn't connect it. More...

 Socket (string host, Word port, SocketType type=stStream)
 creates a Socket and connects it. More...

 Socket (string host, string service, SocketType type=stStream)
 creates a Socket and connects it. More...

 Socket (SocketServer &socketServer)
 creates this Socket from a SocketServer ( as a consequence of the SocketServer accepting a connection ). More...

virtual ~Socket () throw ()
 cleans up. More...

virtual char pop ()
 see class _Input. More...

virtual bool hasMore () const
 see class _Input. More...

virtual long read (char *buffer, long count, bool bWaitAll=true)
 see class _Input. More...

virtual void push (const char &value)
 see class _Output. More...

virtual long write (const char *buffer, long count, bool bWaitAll=true)
 see class _Output. More...

virtual void flush ()
 see class _Output. More...

virtual void connect (string host, Word port, SocketType type=stStream)
 connects the Socket that calls it. More...

virtual void connect (string host, string service, SocketType type=stStream)
 connects the Socket that calls it. More...

virtual void accept (SocketServer &socketServer)
 this is complementary to the SocketServer& constructor. More...

virtual void close ()
 closes the Socket that calls it
Exceptions:
SocketException  .
More...


virtual long readFrom (string &host, Word port, char *buffer, long count, bool bWaitAll=true)
 receives some UDP packets. More...

virtual long writeTo (string host, Word port, const char *buffer, long count, bool bWaitAll=true)
 sends some UDP packets. More...

virtual void setBlocking (bool bBlocking)
 the operations on this Socket will block or not. More...

virtual State state () const throw ()
 whether this Socket is open or closed. More...


Protected Methods

virtual void testState (State state, string location) const
 asserts that the current Socket state is the one we think it is. More...


Protected Attributes

pal::sockets::Handle m_handle
State m_state
 current state of the Socket, see Socket::State. More...


Detailed Description

medium level socket type. allows easy communication.

Note:
dubious design; these classes will hopefully get replaced soon
Todo:
make this thread safe


Member Enumeration Documentation

enum lfc::Socket::State
 

Enumeration values:
stOpen 
stClosed 

enum lfc::Socket::Protocol
 

available communications protocols.

Enumeration values:
pfINET 
pfUNIX 
pfIPX 

enum lfc::Socket::SocketType
 

connection oriented or connectionless.

Enumeration values:
stStream 
stDatagram 

enum lfc::Socket::Flags
 

peek and Out of Band flags.

Enumeration values:
flagPeek 
flagOOB 


Constructor & Destructor Documentation

lfc::Socket::Socket   throw ()
 

creates a Socket but doesn't connect it.

lfc::Socket::Socket string    host,
Word    port,
SocketType    type = stStream
 

creates a Socket and connects it.

Parameters:
host  a string specifying either a hostname or an IP address
port  the port to which the Socket is supposed to connect to on host
type  Socket::stStream or Socket::stDatagram; connection oriented or connectionless Socket
Exceptions:
SocketException 

lfc::Socket::Socket string    host,
string    service,
SocketType    type = stStream
 

creates a Socket and connects it.

Parameters:
host  a string specifying either a hostname or an IP address
service  a service to connect to on host; example of services are tcp, smtp, ftp, ssh, www.
type  Socket::stStream or Socket::stDatagram; connection oriented or connectionless Socket
Exceptions:
SocketException 

lfc::Socket::Socket SocketServer   socketServer
 

creates this Socket from a SocketServer ( as a consequence of the SocketServer accepting a connection ).

Parameters:
socketServer  the SocketServer that accepts some connection to produce this Socket
Exceptions:
SocketException 

lfc::Socket::~Socket   throw () [virtual]
 

cleans up.


Member Function Documentation

char lfc::Socket::pop   [virtual]
 

see class _Input.

Reimplemented from lfc::_Input.

bool lfc::Socket::hasMore   const [virtual]
 

see class _Input.

Reimplemented from lfc::_Input.

long lfc::Socket::read char *    buffer,
long    count,
bool    bWaitAll = true
[virtual]
 

see class _Input.

Todo:
support transfer flags

void lfc::Socket::push const char &    value [virtual]
 

see class _Output.

long lfc::Socket::write const char *    buffer,
long    count,
bool    bWaitAll = true
[virtual]
 

see class _Output.

Todo:
support transfer flags

void lfc::Socket::flush   [virtual]
 

see class _Output.

Reimplemented from lfc::_Output.

void lfc::Socket::connect string    host,
Word    port,
SocketType    type = stStream
[virtual]
 

connects the Socket that calls it.

Parameters:
host  a string specifying either a hostname or an IP address
service  a service to connect to on host; example of services are tcp, smtp, ftp, ssh, www.
type  Socket::stStream or Socket::stDatagram; connection oriented or connectionless Socket
Exceptions:
SocketException 

void lfc::Socket::connect string    host,
string    service,
SocketType    type = stStream
[virtual]
 

connects the Socket that calls it.

Parameters:
host  a string specifying either a hostname or an IP address
service  a service to connect to on host; example of services are tcp, smtp, ftp, ssh, www.
type  Socket::stStream or Socket::stDatagram; connection oriented or connectionless Socket
Exceptions:
SocketException 

void lfc::Socket::accept SocketServer   socketServer [virtual]
 

this is complementary to the SocketServer& constructor.

Parameters:
socketServer  the SocketServer that accepts some connection to produce this Socket
Exceptions:
SocketException 

void lfc::Socket::close   [virtual]
 

closes the Socket that calls it

Exceptions:
SocketException  .

long lfc::Socket::readFrom string &    host,
Word    port,
char *    buffer,
long    count,
bool    bWaitAll = true
[virtual]
 

receives some UDP packets.

Parameters:
host  the machine that sent the packets
port  the peer port to connect to when asking for data
buffer  the buffer to read into
count  the number of bytes you want to read
bWaitAll  blocking until we have all the data or not
Returns:
the number of bytes actually received
Exceptions:
SocketException 

long lfc::Socket::writeTo string    host,
Word    port,
const char *    buffer,
long    count,
bool    bWaitAll = true
[virtual]
 

sends some UDP packets.

Parameters:
host  the machine to send to
port  the peer port to connect to
buffer  the buffer to send from
count  the number of bytes you want to send
bWaitAll  blocking until we have sent all the data or not
Returns:
the number of bytes actually sent
Exceptions:
SocketException 

void lfc::Socket::setBlocking bool    bBlocking [virtual]
 

the operations on this Socket will block or not.

Parameters:
bBlocking  true means the Socket blocks, false that it doesn't
Exceptions:
SocketException 

virtual State lfc::Socket::state   const throw () [inline, virtual]
 

whether this Socket is open or closed.

virtual void lfc::Socket::testState State    state,
string    location
const [inline, protected, virtual]
 

asserts that the current Socket state is the one we think it is.

Parameters:
state  the state we think the Socket should be in at the time of calling the function
location  this is only used if the assertion fails; set it to anything you want to reflect where you were in the program when the assertion failed
Exceptions:
SocketException 


Member Data Documentation

pal::sockets::Handle lfc::Socket::m_handle [protected]
 

State lfc::Socket::m_state [protected]
 

current state of the Socket, see Socket::State.


The documentation for this class was generated from the following files:
Generated on Fri Jan 25 03:13:52 2002 for LFC2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001