GNUMessenger::Network Class Reference

Network abstract base class. More...

#include <basenetwork.h>

Collaboration diagram for GNUMessenger::Network:

Collaboration graph
List of all members.

Public Types

enum  Error {
 Low-Level Network Error Codes. More...
enum  Status {
  Connected, Closed, HostLookupFailure, ConnectionRefused,
  FailedRead, FailedWrite, NotConnected
 Network status.

Public Member Functions

 Network (Protocol *owner)
 Constructor, associates a Protocol with this network.
virtual void connectTo (const string &host, unsigned int port)=0
 Tries to connect to a given host.
virtual string getRemoteIP ()=0
 Return the IP of the remote host if we are connected, empty string otherwise.
virtual bool isConnected ()=0
 Checks to see if connection established.
virtual unsigned long availableData ()=0
 Return how much available data there is waiting to be read.
virtual Status status ()
 Return status.
virtual void sendData (const char *data, unsigned long len)=0
 Send data in a variety of ways.
virtual void sendData (const string &data)
virtual void sendData (const XMLNode &data)
virtual void sendData (const VBuffer &data)=0
virtual void disconnect ()=0
 Disconnect, never throws.
virtual void socketData (byte *&data, unsigned int &len)=0
 Call to retrieve all data available.
virtual void socketData (string &data)=0
virtual void socketData (VBuffer &data)=0
virtual void checkForData ()=0
 Update socket and check for data.
virtual int getSock ()=0
 Return socket handle.
virtual void setOwner (Protocol *protocol)
 Set our owner. The protocol instance we should pass all incoming data to.
unsigned long getSentBytes () const
unsigned long getSentPackets () const
unsigned long getRecvBytes () const
unsigned long getRecvPackets () const
virtual string getHTTP (const string &url)=0

Static Public Member Functions

template<typename T> T NBO (const T &in)
 Network Byte Order paramatrized function.

Protected Attributes

unsigned long m_sentBytes
unsigned long m_recvBytes
unsigned long m_sentPackets
unsigned long m_recvPackets
Status m_status

Detailed Description

Network abstract base class.

Henrik Abelsson

Jesse Lovelace

Definition at line 48 of file basenetwork.h.

Member Enumeration Documentation

enum GNUMessenger::Network::Error

Low-Level Network Error Codes.

Enumeration values:
ERROR_NETWORK_NOERROR  No error happened. Connect() calls should use this.
ERROR_NETWORK_INVOP  Invalid operation.
ERROR_NETWORK_IOERR  Input/Output error.
ERROR_NETWORK_INVADDR  Invalid address passed to socket.
ERROR_NETWORK_INVSOCK  Invalid socket (uninitialized).
ERROR_NETWORK_NOHOST  No corresponding host.
ERROR_NETWORK_WOULDBLOCK  The socket is non-blocking and the operation would block.
ERROR_NETWORK_TIMEDOUT  The timeout for this operation has expired.
ERROR_NETWORK_MEMERR  Memory exhausted.
ERROR_NETWORK_ALLOCERR  Allocation error, specifically a "new" call.
Definition at line 77 of file basenetwork.h.

Member Function Documentation

virtual void GNUMessenger::Network::connectTo const string &  host,
unsigned int  port
[pure virtual]

Tries to connect to a given host.

host The host name to connect to.
port The service to try and reach.
NetworkError If invalid host, port, or socket.

Referenced by GNUMessenger::TocProtocol::login().

virtual bool GNUMessenger::Network::isConnected  )  [pure virtual]

Checks to see if connection established.

True iff socket is connected to the remote host.

template<typename T>
T GNUMessenger::Network::NBO const T &  in  )  [inline, static]

Network Byte Order paramatrized function.

Because Microsoft Visual C++ .NET SUCKS you must define the function body in basenetwork.cpp in ALL of your translation units which use this function call. A sane compiler would allow the use of the 'export' keyword.
Definition at line 67 of file basenetwork.h.
00067 { 00068 #ifdef IS_LITTLE_ENDIAN 00069 return ByteReverse(in); 00070 #else 00071 else return in; 00072 #endif 00073 }

virtual void GNUMessenger::Network::sendData const char *  data,
unsigned long  len
[pure virtual]

Send data in a variety of ways.

NetworkError Raises exception if the socket cannot send this data

Referenced by GNUMessenger::TocProtocol::connectedToServer().

The documentation for this class was generated from the following files:
Generated on Tue Oct 5 14:41:48 2004 for GNU Messenger by doxygen 1.3.8