php8.5
Home/ Manual/ appendices/ List of Supported Socket Transports

List of Supported Socket Transports

The following is a list of the various URL style socket transports that PHP has built-in for use with the streams based socket functions such as fsockopen, and stream_socket_client. These transports do not apply to the Socket Functions of the Sockets extension.

The following is a list of the various URL style socket transports that PHP has built-in for use with the streams based socket functions such as fsockopen(), and stream_socket_client(). These transports do not apply to the Socket Functions of the Sockets extension.

For a list of transports installed in your version of PHP use stream_get_transports().

Internet Domain: TCP, UDP, SSL, and TLS

ssl://, tls://, sslv2:// & sslv3://.

Note

The sslv2:// and sslv3:// transports are obsolete and should not be used. They are documented for backward compatibility only.

Note

If no transport is specified, tcp:// will be assumed.

  • 127.0.0.1
  • fe80::1
  • www.example.com
  • tcp://127.0.0.1
  • tcp://fe80::1
  • tcp://www.example.com
  • udp://www.example.com
  • ssl://www.example.com
  • tls://www.example.com

Internet Domain sockets expect a port number in addition to a target address. In the case of fsockopen() this is specified in a second parameter and therefore does not impact the formatting of transport URL. With stream_socket_client() and related functions as with traditional URLs however, the port number is specified as a suffix of the transport URL delimited by a colon.

  • tcp://127.0.0.1:80
  • tcp://[fe80::1]:80
  • tcp://www.example.com:80
Note

In the second example above, while the IPv4 and hostname examples are left untouched apart from the addition of their colon and portnumber, the IPv6 address is wrapped in square brackets: [fe80::1]. This is to distinguish between the colons used in an IPv6 address and the colon used to delimit the portnumber.

The ssl:// and tls:// transports (available only when openssl support is compiled into PHP) are extensions of the tcp:// transport which include SSL encryption.

ssl:// will attempt to negotiate a secure SSL/TLS connection depending on the capabilities and preferences of both the client and the remote host. The actual protocols that may be used are determined by the OpenSSL configuration and by any options provided through stream_context_create(), such as ssl.crypto_method.

The SSLv2 and SSLv3 protocols are obsolete and insecure. Their use is strongly discouraged and they are no longer enabled by default in modern versions of PHP and OpenSSL.

Unix Domain: Unix and UDG

unix:// and udg://.

  • unix:///tmp/mysock
  • udg:///tmp/mysock

unix:// provides access to a socket stream connection in the Unix domain. udg:// provides an alternate transport to a Unix domain socket using the user datagram protocol.

Unix domain sockets, unlike Internet domain sockets, do not expect a port number. In the case of fsockopen() the portno parameter should be set to 0.

Note

Unix domain sockets are not supported on Windows.

Source: appendices/transports.xml · from the official PHP manual (php/doc-en)