Net_Socket::connect() – connects to a server


require_once 'Net/Socket.php';

boolean Net_Socket::connect ( string $addr , integer $port , boolean $persistent = null , integer $timeout = null , array $options = null )


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.


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


This function can not be called statically.

Net_Socket (Previous) disconnects from a server (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.