PEAR Manual
Prev |  | Next

# Net_NNTP_Client::connect()

Net_NNTP_Client::connect() -- Connects to a NNTP-server

## Synopsis

    require_once 'Net/NNTP/Client.php';

``boolean Net_NNTP_Client::connect` ([string $host = `NET_NNTP_PROTOCOL_DEFAULT_HOST` [, integer $port = `NET_NNTP_PROTOCOL_DEFAULT_PORT`]])`

## Description

Connect to a specific NNTP-server

## Parameter

- `$host` - Hostname of the NNTP-server. Default=`NET_NNTP_PROTOCOL_DEFAULT_HOST`

- `$port` - Port, where the NNTP-server listens. Default=`NET_NNTP_PROTOCOL_DEFAULT_PORT`

## Return value

`boolean` - Returns `TRUE` on success, PEAR_Error on failure.

## Throws

Table 48-1. Possible PEAR_Error values

Error code | Error message | Reason | Solution
--- | --- | --- | ---
`NULL` | `"Could not connect to NNTP-server $host"` or `"Not connected"` | The connection couldn't be established because wrong hostname/ip-address or port the host itself isn't linked to a network a firewall doesn't allow access | Check for server name, the connection to the net and possible firewalls on client or server side.

## Note

This function can not be called statically.

## See

Net_NNTP::quit(), Net_NNTP::pepareConnection()

## Example

Example 48-1. Using connect()
    require_once 'Net/NNTP/Client.php';

    $nntp = new Net_NNTP_Client();
    $ret = $nntp->connect('news.php.net');
    if( PEAR::isError($ret)) {
        // handle error
    } else {
        // success
    }

Prev | Home | Next
Net_NNTP_Client::`authenticate`() | Up | Net_NNTP_Client::connectAuthenticated()