Aller au contenu

Do you support sockets with PHP?

Ce contenu n’est pas encore disponible dans votre langue.

Yes. PHP socket functions are available on Ruachost hosting.

Sockets let your PHP scripts open network connections directly, for example to talk to another server or a service that doesn’t use plain HTTP. You can use:

  • The sockets extension, with functions such as socket_create(), socket_connect() and socket_write().
  • Stream functions such as fsockopen() and stream_socket_client(), which are often simpler.
<?php
$fp = fsockopen('example.com', 80, $errno, $errstr, 10);
if (!$fp) {
echo "Error: $errstr ($errno)";
}

Cette page vous a-t-elle aidé ?