Http/Client/Adapter/Socket.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Http
- Subpackage
- Client_Adapter
- Version
- $Id$
\Zend_Http_Client_Adapter_Socket
Package: Zend_Http\Client_Adapter









Returns
Details
A sockets based (stream_socket_client) adapter class for Zend_Http_Client. Can be used
on almost every PHP environment, and does not require any special extensions.
- Implements
- Children
- \Zend_Http_Client_Adapter_Proxy
- \Zend_Gdata_App_LoggingHttpClientAdapterSocket
- \Zend_Gdata_HttpAdapterStreamingSocket
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties

array $config = array('persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslusecontext' => false)Parameters array
Default value
array('persistent' => false, 'ssltransport' => 'ssl', 'sslcert' => null, 'sslpassphrase' => null, 'sslusecontext' => false)Details- Type
- array

array $connected_to = array(null, null)What host/port are we connected to?
Default value
array(null, null)Details- Type
- array

string $method = nullRequest method - will be set by write() and might be used by read()
Default value
nullDetails- Type
- string
Methods

__destruct() : voidDestructor: make sure the socket is disconnected
If we are in persistent TCP mode, will not close the connection

_checkSocketReadTimeout() : voidCheck if the socket has timed out - if so close connection and throw an exception
Throws
| Exception | Description |
|---|---|
| \Zend_Http_Client_Adapter_Exception | with READ_TIMEOUT code |

connect(string $host, int $port = 80, boolean $secure = false) : voidConnect to the remote server
Parameters
| Name | Type | Description |
|---|---|---|
| $host | string | |
| $port | int | |
| $secure | boolean |

getStreamContext() : resourceGet the stream context for the TCP connection to the server.
If no stream context is set, will create a default one.
Returns| Type | Description |
|---|---|
| resource |

setConfig( $config = array()) : voidSet the configuration array for the adapter
Parameters
| Name | Type | Description |
|---|---|---|
| $config |

setOutputStream(resource $stream) : \Zend_Http_Client_Adapter_SocketSet output stream for the response
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $stream | resource |
| Type | Description |
|---|---|
| \Zend_Http_Client_Adapter_Socket |

setStreamContext(mixed $context) : \Zend_Http_Client_Adapter_SocketSet the stream context for the TCP connection to the server
Can accept either a pre-existing stream context resource, or an array
of stream options, similar to the options array passed to the
stream_context_create() PHP function. In such case a new stream context
will be created using the passed options.
Parameters| Name | Type | Description |
|---|---|---|
| $context | mixed | Stream context or array of context options |
| Type | Description |
|---|---|
| \Zend_Http_Client_Adapter_Socket |
- Since
- Zend Framework 1.9

write(string $method, \Zend_Uri_Http $uri, string $http_ver = '1.1', array $headers = array(), string $body = '') : stringSend request to the remote server
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| $method | string | |
| $uri | \Zend_Uri_Http | |
| $http_ver | string | |
| $headers | array | |
| $body | string |
| Type | Description |
|---|---|
| string | Request as string |