PHP: php_stream_sock_open_host - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

php_stream_sock_open_unix php_stream_sock_open_from_socket

Last updated: Fri, 26 Jan 2007

view this page in

# php_stream_sock_open_host

php_stream_sock_open_host -- Open a connection to a host and return a stream

## Description

php_stream * php_stream_sock_open_host ( const char * host, unsigned short port, int socktype, struct timeval * timeout, int persistent )

php_stream_sock_open_host() establishes a connect to the specified `host` and `port`. `socktype` specifies the connection semantics that should apply to the connection. Values for `socktype` are system dependent, but will usually include (at a minimum) `SOCK_STREAM` for sequenced, reliable, two-way connection based streams (TCP), or `SOCK_DGRAM` for connectionless, unreliable messages of a fixed maximum length (UDP).

`persistent` is a flag the controls whether the stream is opened as a persistent stream. Generally speaking, this parameter will usually be 0.

If not NULL, `timeout` specifies a maximum time to allow for the connection to be made. If the connection attempt takes longer than the timeout value, the connection attempt is aborted and NULL is returned to indicate that the stream could not be opened.

> Замечание: The timeout value does not include the time taken to perform a DNS lookup. The reason for this is because there is no portable way to implement a non-blocking DNS lookup.

> The timeout only applies to the connection phase; if you need to set timeouts for subsequent read or write operations, you should use php_stream_sock_set_timeout() to configure the timeout duration for your stream once it has been opened.

The streams API places no restrictions on the values you use for `socktype`, but encourages you to consider the portability of values you choose before you release your extension.

add a note User Contributed Notes
php_stream_sock_open_host
There are no user contributed notes for this page.
php_stream_sock_open_unix php_stream_sock_open_from_socket

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST