PEAR Manual
Prev |  | Next

# Net_Socket::connect()

Net_Socket::connect() -- connects to a server

## Synopsis

    require_once 'Net/Socket.php';

``boolean Net_Socket::connect` (string $addr, integer $port, boolean [$persistent = `NULL`], integer [$timeout = `NULL`])`

## Description

Connect to the specified port. If called when the socket is already connected, it disconnects and connects again.

## 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
--- | --- | --- | ---
every | every | The connection could not be established because wrong server name or adress the host itself is not link to a network a firewall does not allow an 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_Socket::disconnect()

Prev | Home | Next
Net_Socket | Up | Net_Socket::disconnect()