# Socket Class Reference
[Various accompanying utilities]

List of all members.

## Public Member Functions

| __construct ()
| __destruct ()
| setHost ($host)
| getHost ()
| setPort ($port)
| getPort ()
| isConnected ()
| getInputStream ()
| getOutputStream ()
| connect ($connectTimeout=self::DEFAULT_TIMEOUT)
| setReadTimeout ($timeout)
| setWriteTimeout ($timeout)
| setTimeout ($timeout)
| getReadTimeout ()
| getWriteTimeout ()
| read ($length)
| returns 8-bit string or false on timeout or null on eof
| write ($buffer, $length=null)
| returns number of written bytes or false on timeout
| isTimedOut ()
| shutdownInput ()
| shutdownOutput ()
| close ()

## Static Public Member Functions

static | create ()

## Public Attributes

const | DEFAULT_TIMEOUT = 1000
const | EAGAIN = 11

## Private Member Functions

| checkRead ()
| checkWrite ()

## Static Private Member Functions

static | getSeconds ($timeout)
static | getMicroseconds ($timeout)

## Private Attributes

| $socket = null
| $connected = false
| $host = null
| $port = null
| $inputStream = null
| $outputStream = null
| $closed = false
| $inputShutdown = false
| $outputShutdown = false
| $readTimeout = null
| $writeTimeout = null

## Detailed Description

Definition at line 15 of file Socket.class.php.

## Constructor & Destructor Documentation

Socket::__construct | ( |  | ) |

Definition at line 38 of file Socket.class.php.

Socket::__destruct | ( |  | ) |

Definition at line 53 of file Socket.class.php.

References close().

Here is the call graph for this function:

## Member Function Documentation

Socket::checkRead | ( |  | ) | `[private]`

Definition at line 367 of file Socket.class.php.

Referenced by getInputStream(), and read().

Socket::checkWrite | ( |  | ) | `[private]`

Definition at line 376 of file Socket.class.php.

Referenced by getOutputStream(), and write().

Socket::close | ( |  | ) |

Returns:
  Socket

Definition at line 342 of file Socket.class.php.

References shutdownInput(), and shutdownOutput().

Referenced by __destruct().

Here is the call graph for this function:

Socket::connect | ( | $ | connectTimeout = `self::DEFAULT_TIMEOUT` | ) |

Returns:
  Socket

Definition at line 134 of file Socket.class.php.

References Assert::isTrue(), setReadTimeout(), and setWriteTimeout().

Here is the call graph for this function:

static Socket::create | ( |  | ) | `[static]`

Returns:
  Socket

Definition at line 67 of file Socket.class.php.

Socket::getHost | ( |  | ) |

Definition at line 84 of file Socket.class.php.

Socket::getInputStream | ( |  | ) |

Returns:
  SocketInputStream

Definition at line 114 of file Socket.class.php.

References checkRead().

Here is the call graph for this function:

static Socket::getMicroseconds | ( | $ | timeout | ) | `[static, private]`

Definition at line 362 of file Socket.class.php.

Socket::getOutputStream | ( |  | ) |

Returns:
  SocketOutputStream

Definition at line 124 of file Socket.class.php.

References checkWrite().

Here is the call graph for this function:

Socket::getPort | ( |  | ) |

Definition at line 101 of file Socket.class.php.

Socket::getReadTimeout | ( |  | ) |

Definition at line 239 of file Socket.class.php.

static Socket::getSeconds | ( | $ | timeout | ) | `[static, private]`

Definition at line 357 of file Socket.class.php.

Socket::getWriteTimeout | ( |  | ) |

Definition at line 247 of file Socket.class.php.

Socket::isConnected | ( |  | ) |

Definition at line 106 of file Socket.class.php.

Socket::isTimedOut | ( |  | ) |

Definition at line 310 of file Socket.class.php.

Referenced by read(), and write().

Socket::read | ( | $ | length | ) |

returns 8-bit string or false on timeout or null on eof

Definition at line 257 of file Socket.class.php.

References checkRead(), and isTimedOut().

Here is the call graph for this function:

Socket::setHost | ( | $ | host | ) |

Returns:
  Socket

Definition at line 75 of file Socket.class.php.

References $host, and Assert::isNull().

Here is the call graph for this function:

Socket::setPort | ( | $ | port | ) |

Returns:
  Socket

Definition at line 92 of file Socket.class.php.

References $port, and Assert::isNull().

Here is the call graph for this function:

Socket::setReadTimeout | ( | $ | timeout | ) |

Returns:
  Socket

Definition at line 196 of file Socket.class.php.

Referenced by connect(), and setTimeout().

Socket::setTimeout | ( | $ | timeout | ) |

Returns:
  Socket

Definition at line 230 of file Socket.class.php.

References setReadTimeout(), and setWriteTimeout().

Here is the call graph for this function:

Socket::setWriteTimeout | ( | $ | timeout | ) |

Returns:
  Socket

Definition at line 213 of file Socket.class.php.

Referenced by connect(), and setTimeout().

Socket::shutdownInput | ( |  | ) |

Returns:
  Socket

Definition at line 318 of file Socket.class.php.

Referenced by close().

Socket::shutdownOutput | ( |  | ) |

Returns:
  Socket

Definition at line 330 of file Socket.class.php.

Referenced by close().

Socket::write | ( | $ | buffer,
|  | $ | length = `null` |
| ) |  |  |

returns number of written bytes or false on timeout

Definition at line 284 of file Socket.class.php.

References checkWrite(), and isTimedOut().

Here is the call graph for this function:

## Member Data Documentation

Socket::$closed = false`[private]`

Definition at line 30 of file Socket.class.php.

Socket::$connected = false`[private]`

Definition at line 22 of file Socket.class.php.

Socket::$host = null`[private]`

Definition at line 24 of file Socket.class.php.

Referenced by setHost().

Socket::$inputShutdown = false`[private]`

Definition at line 31 of file Socket.class.php.

Socket::$inputStream = null`[private]`

Definition at line 27 of file Socket.class.php.

Socket::$outputShutdown = false`[private]`

Definition at line 32 of file Socket.class.php.

Socket::$outputStream = null`[private]`

Definition at line 28 of file Socket.class.php.

Socket::$port = null`[private]`

Definition at line 25 of file Socket.class.php.

Referenced by setPort().

Socket::$readTimeout = null`[private]`

Definition at line 35 of file Socket.class.php.

Socket::$socket = null`[private]`

Definition at line 21 of file Socket.class.php.

Socket::$writeTimeout = null`[private]`

Definition at line 36 of file Socket.class.php.

const Socket::DEFAULT_TIMEOUT = 1000

Definition at line 17 of file Socket.class.php.

const Socket::EAGAIN = 11

Definition at line 19 of file Socket.class.php.

The documentation for this class was generated from the following file:

- main/Utils/IO/Socket.class.php