56. Class

56.1. Zend\Http\Client\Adapter\Socket

A sockets based (streamsocketclient) adapter class for ZendHttpClient. Can be used on almost every PHP environment, and does not require any special extensions.

56.1.1. Methods

56.1.1.1. __construct

__construct()

Adapter constructor, currently empty. Config is set using setOptions()

56.1.1.2. setOptions

setOptions()

Set the configuration array for the adapter

Parameters:array|Traversable
Throws AdapterExceptionInvalidArgumentException:
 

56.1.1.3. getConfig

getConfig()

Retrieve the array of all configuration options

Return type:array

56.1.1.4. setStreamContext

setStreamContext()

Set 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:mixed – Stream context or array of context options
Throws ExceptionInvalidArgumentException:
 
Return type:Socket

56.1.1.5. getStreamContext

getStreamContext()

Get the stream context for the TCP connection to the server.

If no stream context is set, will create a default one.

Return type:resource

56.1.1.6. connect

connect()

Connect to the remote server

Parameters:
  • string
  • int
  • bool
Throws AdapterExceptionRuntimeException:
 

56.1.1.7. write

write()

Send request to the remote server

Parameters:
  • string
  • ZendUriUri
  • string
  • array
  • string
Throws AdapterExceptionRuntimeException:
 
Return type:

string Request as string

56.1.1.8. read

read()

Read response from server

Return type:string

56.1.1.9. close

close()

Close the connection to the server

56.1.1.10. _checkSocketReadTimeout

_checkSocketReadTimeout()

Check if the socket has timed out - if so close connection and throw an exception

56.1.1.11. setOutputStream

setOutputStream()

Set output stream for the response

Parameters:resource
Return type:ZendHttpClientAdapterSocket

56.1.1.12. __destruct

__destruct()

Destructor: make sure the socket is disconnected

If we are in persistent TCP mode, will not close the connection