Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Copyright 2013-2017 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Copyright: 2013-2017 Horde LLC
License: http://www.horde.org/licenses/lgpl21 LGPL 2.1
File Size: 336 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Client:: (12 methods):
  __construct()
  __get()
  __clone()
  __sleep()
  startTls()
  close()
  getStatus()
  gets()
  read()
  write()
  _connect()
  _checkStream()


Class: Client  - X-Ref

Utility interface for establishing a stream socket client.

__construct($host, $port = null, $timeout = 30, $secure = false,$context = array()   X-Ref
Constructor.

param: string $host      Hostname of remote server (can contain
param: integer $port     Port number of remote server.
param: integer $timeout  Connection timeout (in seconds).
param: mixed $secure     Security layer requested. One of:
param: array $context    Any context parameters passed to
param: array $params     Additional options.

__get($name)   X-Ref
No description

__clone()   X-Ref
This object can not be cloned.


__sleep()   X-Ref
This object can not be serialized.


startTls()   X-Ref
Start a TLS connection.

return: boolean  Whether TLS was successfully started.

close()   X-Ref
Close the connection.


getStatus()   X-Ref
Returns information about the connection.

Currently returns four entries in the result array:
- timed_out (bool): The socket timed out waiting for data
- blocked (bool): The socket was blocked
- eof (bool): Indicates EOF event
- unread_bytes (int): Number of bytes left in the socket buffer

return: array  Information about existing socket resource.

gets($size)   X-Ref
Returns a line of data.

return: string  $size bytes of data from the socket
param: int $size  Reading ends when $size - 1 bytes have been read,

read($size)   X-Ref
Returns a specified amount of data.

return: string  $size bytes of data from the socket.
param: integer $size  The number of bytes to read from the socket.

write($data)   X-Ref
Writes data to the stream.

param: string $data  Data to write.

_connect($host, $port, $timeout, $secure, $context, $retries = 0)   X-Ref
Connect to the remote server.


_checkStream()   X-Ref
Throws an exception is the stream is not a resource.