Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

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: 337 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.

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

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

param: integer $size  The number of bytes to read from the socket.
return: string  $size bytes of data 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.