Home > simplesocket

simplesocket

Simplesocket is a project mainly written in PHP, it's free.

A simple socket client for PHP 5.2+, bundled with a collection of useful client libraries.

A Simple Socket Client for PHP 5.2+

This library contains one class, SimpleSocketClient, that implements a generic socket client. You can either inherit this class or use instances of this class to write client libraries for any modern text-based protocol.

Fully featured client libraries, included as examples:

  • Clamd
  • HTTP
  • Memcached
  • Redis

Features:

  • Socket creation, reading, and writing (of course).
  • Lazy loading : will not connect until actually needed.
  • Automatically deal with end-of-line CRLF sequences.
  • Basic key validation and command building helper methods.

Public methods:

  • __construct($host, $port, $timeout = 5)
  • connect()
  • disconnect()
  • read($bytes, $autonewline = true, $trim = true)
  • readline($trim = true)
  • write($string, $autonewline = true)
  • validate_key($key)
  • build_command()

License: MIT License.

Previous:sample_app