PHP 手冊
上一頁 |  | 下一頁

# 附錄 N.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 Sockets Extension.

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

# Internet Domain: TCP, UDP, SSL, and TLS

PHP 3, PHP 4, PHP 5. ssl:// & tls:// since PHP 4.3

> 備注: 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

> IPv6 numeric addresses with port numbers: 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 includes SSL encryption. Since PHP 4.3.0 OpenSSL support must be statically compiled into PHP, since PHP 5.0.0 it may be compiled as a module or statically.

表格 N-1. Context options for ssl:// and tls:// transports (since PHP 4.3.2)

Name | Usage | Default
--- | --- | ---
verify_peer | `TRUE` or `FALSE`. Require verification of SSL certificate used. | `FALSE`
allow_self_signed | `TRUE` or `FALSE`. Allow self-signed certificates. | `FALSE`
cafile | Location of Certificate Authority file on local filesystem which should be used with the verify_peer context option to authenticate the identity of the remote peer. |
capath | If cafile is not specified or if the certificate is not found there, the directory pointed to by capath is searched for a suitable certificate. capath must be a correctly hashed certificate directory. |
local_cert | Path to local certificate file on filesystem. It must be a PEM encoded file which contains your certificate and private key. It can optionally contain the certificate chain of issuers. |
passphrase | Passphrase with which your local_cert file was encoded. |
CN_match | Common Name we are expecting. PHP will perform limited wildcard matching. If the Common Name does not match this, the connection attempt will fail. |

> 備注: Because ssl:// is the underlying transport for the https:// and ftps:// wrappers, any context options which apply to ssl:// also apply to https:// and ftps://.

上一頁 | 最開頭 | 下一頁
Compression Filters | 上一層 | Unix Domain: Unix and UDG