Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Cabal::NetBase Class Reference

Basic functionality service abstract class. More...

#include <cabal_netbase.h>

Inheritance diagram for Cabal::NetBase:

Inheritance graph
[legend]
List of all members.

Static Public Member Functions

bool init () throw (InitError)
bool exit () throw (DataIncompleteError)
RawSocket createTCPSocket ()
 Create a socket with cabal properties.

RawSocket createUDPSocket ()
int closeSocket (RawSocket s)
 Closes a underlying OS system socket resource.

bool bind (const RawSocket s, const SockAddrInet &addr)
 Binds a socket to a local address and/or port.

bool connect (const RawSocket s, const SockAddrInet &addr)
 Connect a socket with a remote address.

bool listen (const RawSocket m_skCom, const int incomingMax)
 Prepare a socket to receive connections.

RawSocket accept (const RawSocket s, SockAddrInet *in)
 Accepts incoming connections.

void initSockAddr (SockAddrInet &attr)
 Address initializer.

void initSockAddr (SockAddrInet &attr, const char *ip)
void initSockAddr (SockAddrInet &attr, const char *ip, const NetPort port)
void initSockAddr (SockAddrInet &attr, const NetAddr data, const NetPort port)
bool SockAddrIsZero (const SockAddrInet &addr)
 Socket Address related functions.

bool SockAddrIsSame (const SockAddrInet &addr, const SockAddrInet &addr1)
void SockAddrSetPort (SockAddrInet &attr, NetPort port)
NetPort SockAddrGetPort (const SockAddrInet &attr)
bool getHostList (const std::string &name, std::string &real_name, char *real_ip, NetAddr *other_addrs, int na_count)
 Return a threadsafe value for gethostbyname.

bool addrToString (const SockAddrInet &addr, char *dest)
 Returns a string representation of a given address.

bool addrToString (const NetAddr addr, char *dest)
 Returns a string representation of a given address.

bool stringToAddr (const char *source, SockAddrInet &addr)
 Creates Socket address from a given string representation If the source string is not in any convertible ip address representation, the function return false.

bool isAddressString (const char *source)
 Returns true if the given string is a valid IP address representation.

int errorCode ()
 Return last OS dependant error code.

void resetError ()
 Clears OS level error code.

std::string errorDescription (const int osCode)
 Returns the error description of a given code.

RawSocket dup (RawSocket s)
 Duplicates an handle.

bool inProgress ()
 True if current low level error means "operation in progress".

bool errorAgain ()
 True if current low level error means "try again".

bool errorAgain (const int error)
 True if parameter is an error code meaning "try again".

bool errorPipe ()
 True if current low level error means "broken pipe".

void setNonBlocking (RawSocket s)
 System specific way to set socket as nonblocking.

void setBlocking (RawSocket s)
 System specific way to set socket as blocking.

void setTCPDefaults (const RawSocket s)
 Sets default TCP attributes on the socket.

bool validSocket (const RawSocket s)
 True if socket is a valid socket (not a return error code).

void invalidate (RawSocket &s)
 Make s to become an "invalid socket" marker.

int getSocketOption (const RawSocket s, const int level, int &iErrval)
 System specific way to set a socket file control option.

int send (const RawSocket s, const void *buffer, const int len, const int params)
 System specific send call.

int recv (const RawSocket s, void *buffer, const int len, const int params)
 System specific receive call.

int sendto (const RawSocket s, const void *buffer, const int len, const int params, const SockAddrInet *remote, const int remsize)
 System specific send to address call.

int recvfrom (const RawSocket s, void *buffer, const int len, const int params, SockAddrInet *remote, int *remsize)
 System specific receive from address call.

void shutdown (const RawSocket s)
 System specific way to close a TCP connection cleanly.

void sleep (const int msecs)
 Used to sleep.

NetPort hostToNetPort (const NetPort data)
 Host to network byte swapping.

NetAddr hostToNetAddr (const NetAddr data)
NetPort netToHostPort (const NetPort data)
NetAddr netToHostAddr (const NetAddr data)
MSECS timeOfDay ()
 Returns the time of day in milliseconds since midnight.


Detailed Description

Basic functionality service abstract class.

Definition at line 47 of file cabal_netbase.h.


Member Function Documentation

RawSocket Cabal::NetBase::accept const RawSocket  s,
SockAddrInet *  in
[static]
 

Accepts incoming connections.

Returns:
on failure an invalid raw socket, on success a valid one.

Reimplemented in Cabal::Net_WSA.

bool Cabal::NetBase::addrToString const NetAddr  addr,
char *  dest
[static]
 

Returns a string representation of a given address.

Sometimes it's handy to have the function that acts directly on the NetAddr element that it's inside SockAddrInet, instead of the version that acts on the whole structure.

bool Cabal::NetBase::addrToString const SockAddrInet &  addr,
char *  dest
[static]
 

Returns a string representation of a given address.

Puts into dest, that must be long CABAL_MAX_IP_SIZE to accept the returned data. On error, returns false; this may be because addr is not valid, (i.e. it has an unknown address family).

Note:
the destination string will not contain any indicator of the IP port stored in addr.
Usually, it returns true.
Parameters:
addr the address to be converted
dest the destination
Returns:
true on success, false on error.

Reimplemented in Cabal::Net_WSA.

bool Cabal::NetBase::bind const RawSocket  s,
const SockAddrInet &  addr
[static]
 

Binds a socket to a local address and/or port.

returns false on failure.

Reimplemented in Cabal::Net_WSA.

void Cabal::NetBase::setTCPDefaults const RawSocket  s  )  [static]
 

Sets default TCP attributes on the socket.

For Cabal, they are keep alive and reuse address options.

Reimplemented in Cabal::Net_WSA.

void Cabal::NetBase::sleep const int  msecs  )  [static]
 

Used to sleep.

Really, this function should be used in other libraries, but it turns tobe useful for portable tests.

Reimplemented in Cabal::Net_WSA.

bool Cabal::NetBase::stringToAddr const char *  source,
SockAddrInet &  addr
[static]
 

Creates Socket address from a given string representation If the source string is not in any convertible ip address representation, the function return false.

Note:
the source string may not contain ports specification.
Parameters:
addr the
dest the destination socket address.
Returns:
true on success false on error.

Reimplemented in Cabal::Net_WSA.

MSECS Cabal::NetBase::timeOfDay  )  [static]
 

Returns the time of day in milliseconds since midnight.

Used to temporize sendings.

Reimplemented in Cabal::Net_WSA.


The documentation for this class was generated from the following file:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5