class ppsocket

A class for dealing with sockets. More...

Definition#include <lib/ppsocket.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A class for dealing with sockets.

 ppsocket ()

Constructs a ppsocket

 ppsocket (const ppsocket&)

Copy constructor

ppsocket ()

[virtual]

Destructor

bool  connect (const char * const Peer, int PeerPort, const char * const Host = NULL, int HostPort = 0)

[virtual]

Connects to a given host.

Parameters:
PeerThe Host to connect to (name or dotquad-string).
PeerPortThe port to connect to.
HostThe local address to bind to.
HostPortThe local port to bind to.

Returns: true on success, false otherwise.

bool  reconnect ()

[virtual]

Reopens the connection after closing it.

Returns: true on success, false otherwise.

std::string  toString ()

[virtual]

Retrieve a string representation of the ppsocket.

Returns: a string in the form "<host>:<hostport> -> <peer>:<peerport>" where elements not known, are replaced by "???" and none-existing elements are represented by the word "none".

bool  listen (const char * const Host, int Port)

[virtual]

Starts listening.

Parameters:
HostThe local address to bind to.
PortThe local port to listen on.

Returns: true on success, false otherwise.

ppsocketaccept (std::string *Peer, IOWatch *)

Accept a connection.

Parameters:
PeerIf non-Null, the peer's name is returned here.

Returns: A pointer to a new instance for the accepted connection or NULL if an error happened.

bool  dataToGet (int sec, int usec)

[const]

Check and optionally wait for incoming data.

Parameters:
secTimeout in seconds
usecTimeout in microseconds

Returns: true if data is available, false otherwise.

int  getBufferStore (bufferStore &a, bool wait = true)

Receive data into a bufferStore .

Parameters:
aThe bufferStore to fill with received data.
waitIf true, wait until something is received, else return if no data is available.

Returns: 1 if a bufferStore received, 0, if no bufferStore received, -1 on error.

bool  sendBufferStore (const bufferStore &a)

Sends data from a bufferStore .

Parameters:
aThe bufferStore to send.

Returns: true on success, false otherwise.

bool  closeSocket (void)

Closes the connection.

Returns: true on success, false otherwise.

bool  bindSocket (const char * const Host, int Port)

Binds to a local address and port.

Parameters:
HostThe local address to bind to.
PortThe local port to listen on.

Returns: true on success, false otherwise.

bool  bindInRange (const char * const Host, int Low, int High, int Retries)

Tries repeated binds to a local address and port. If Retries is <= High - Low, then the port to bind is randomly chosen in the given range. Otherwise, all ports starting from High up to Low are tried in sequence.

Parameters:
HostThe local address to bind to.
LowThe lowest local port to listen on.
HighThe highest local port to listen on.
RetriesThe number of retries until giving up.

Returns: true on success, false otherwise.

bool  linger (bool LingerOn, int LingerTime = 0)

Sets the linger parameter of the socket.

Parameters:
LingerOntrue, if lingering should be on.
LingerTimeIf lingering is on, the linger-time.

Returns: true on success, false otherwise.

bool  getPeer (std::string *Peer, int *Port)

Retrieves peer information.

Parameters:
PeerThe peers name is returned here.
PortThe peers port is returned here.

Returns: true on success, false otherwise.

bool  getHost (std::string *Host, int *Port)

Retrieves local information.

Parameters:
HostThe local name is returned here.
PortThe local port is returned here.

Returns: true on success, false otherwise.

void  setWatch (IOWatch *watch)

Registers an IOWatch for this socket. This IOWatch gets the socket added/removed automatically.

Parameters:
watchThe IOWatch to register.


Generated by: felfert@usw-pr-shell1.sourceforge.net on Sat Aug 10 18:46:04 2002, using kdoc 2.0a36.