# class ppsocket

The socket to be used for connecting to the ncpd daemon. More...

Definition | `#include <ppsocket.h>`
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- ppsocket ()
- ppsocket (const ppsocket&)
- virtual ~ppsocket ()
- virtual bool connect (const char * const Peer, int PeerPort, const char * const Host = NULL, int HostPort = 0)
- virtual bool reconnect ()
- virtual std::string toString ()
- virtual bool listen (const char * const Host, int Port)
- ppsocket * accept (std::string *Peer, IOWatch *)
- bool dataToGet (int sec, int usec) const
- int getBufferStore (bufferStore &a, bool wait = true)
- bool sendBufferStore (const bufferStore &a)
- bool closeSocket (void)
- bool bindSocket (const char * const Host, int Port)
- bool bindInRange (const char * const Host, int Low, int High, int Retries)
- bool linger (bool LingerOn, int LingerTime = 0)
- bool getPeer (std::string *Peer, int *Port)
- bool getHost (std::string *Host, int *Port)
- void setWatch (IOWatch *watch)

## Detailed Description

The socket to be used for connecting to the ncpd daemon.

ppsocket ()

### ppsocket

Constructs a ppsocket

ppsocket (const ppsocket&)

### ppsocket

Copy constructor

~ppsocket ()

### ~ppsocket

[virtual]

Destructor

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

### connect

[virtual]

Connects to a given host.

Parameters:

Peer | The Host to connect to (name or dotquad-string).
PeerPort | The port to connect to.
Host | The local address to bind to.
HostPort | The local port to bind to.

Returns: true on success, false otherwise.

bool reconnect ()

### reconnect

[virtual]

Reopens the connection after closing it.

Returns: true on success, false otherwise.

std::string toString ()

### 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)

### listen

[virtual]

Starts listening.

Parameters:

Host | The local address to bind to.
Port | The local port to listen on.

Returns: true on success, false otherwise.

ppsocket * accept (std::string *Peer, IOWatch *)

### accept

Accept a connection.

Parameters:

Peer | If 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)

### dataToGet

[const]

Check and optionally wait for incoming data.

Parameters:

sec | Timeout in seconds
usec | Timeout in microseconds

Returns: true if data is available, false otherwise.

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

### getBufferStore

Receive data into a bufferStore .

Parameters:

a | The bufferStore to fill with received data.
wait | If 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)

### sendBufferStore

Sends data from a bufferStore .

Parameters:

a | The bufferStore to send.

Returns: true on success, false otherwise.

bool closeSocket (void)

### closeSocket

Closes the connection.

Returns: true on success, false otherwise.

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

### bindSocket

Binds to a local address and port.

Parameters:

Host | The local address to bind to.
Port | The local port to listen on.

Returns: true on success, false otherwise.

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

### bindInRange

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:

Host | The local address to bind to.
Low | The lowest local port to listen on.
High | The highest local port to listen on.
Retries | The number of retries until giving up.

Returns: true on success, false otherwise.

bool linger (bool LingerOn, int LingerTime = 0)

### linger

Sets the linger parameter of the socket.

Parameters:

LingerOn | true, if lingering should be on.
LingerTime | If lingering is on, the linger-time.

Returns: true on success, false otherwise.

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

### getPeer

Retrieves peer information.

Parameters:

Peer | The peers name is returned here.
Port | The peers port is returned here.

Returns: true on success, false otherwise.

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

### getHost

Retrieves local information.

Parameters:

Host | The local name is returned here.
Port | The local port is returned here.

Returns: true on success, false otherwise.

void setWatch (IOWatch *watch)

### setWatch

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

Parameters:

watch | The IOWatch to register.

Generated by: rrt on drom on Mon Nov 26 16:06:15 2007, using kdoc 2.0a54.