Dotclear 2.25
|
Network base. More...
Public Member Functions | |
__construct (string $host, int $port, int $timeout=10) | |
__destruct () | |
host (?string $host=null) | |
port (?int $port=null) | |
timeout (?int $timeout=null) | |
setBlocking (bool $block) | |
open () | |
close () | |
write ($data) | |
flush () | |
isOpen () | |
Protected Member Functions | |
iterator () | |
Protected Attributes | |
$_host | |
$_port | |
$_transport = '' | |
$_timeout | |
$_handle | |
Network base.
This class handles network socket through an iterator.
__construct | ( | string | $host, |
int | $port, | ||
int | $timeout = 10 |
||
) |
Class constructor
string | $host | Server host |
int | $port | Server port |
int | $timeout | Connection timeout |
host | ( | ?string | $host = null | ) |
Get / Set host
If $host is set, set $_host
and returns true. Otherwise, returns $_host
value.
string | $host | Server host |
References $_host.
Referenced by htmlValidator\__construct(), akismet\callFunc(), netHttp\doRequest(), netHttp\getRequestURL(), netHttp\setHost(), and akismet\verify().
port | ( | ?int | $port = null | ) |
Get / Set port
If $port is set, set $_port
and returns true. Otherwise, returns $_port
value.
int | $port | Server port |
References $_port.
Referenced by netHttp\doRequest(), netHttp\getRequestURL(), and netHttp\setHost().
timeout | ( | ?int | $timeout = null | ) |
Get / Set timeout
If $timeout is set, set $_timeout
and returns true. Otherwise, returns $_timeout
value.
int | $timeout | Connection timeout |
References $_timeout.
Referenced by htmlValidator\__construct(), and netHttp\setTimeout().
setBlocking | ( | bool | $block | ) |
Set blocking
Sets blocking or non-blocking mode on the socket.
bool | $block |
References isOpen().
open | ( | ) |
Open connection.
Opens socket connection and Returns an object of type netSocketIterator
which can be iterate with a simple foreach loop.
References iterator().
Referenced by netHttp\doRequest().
close | ( | ) |
write | ( | $data | ) |
Send data
Sends data to current socket and returns an object of type netSocketIterator
which can be iterate with a simple foreach loop.
$data can be a string or an array of lines.
Example:
<?php $s = new netSocket('www.google.com',80,2); $s->open(); $data = [ 'GET / HTTP/1.0' ]; foreach($s->write($data) as $v) { echo $v."\n"; } $s->close(); ?>
string | array | $data | Data to send |
References isOpen(), and iterator().
Referenced by netHttp\doRequest().
flush | ( | ) |
|
protected |
isOpen | ( | ) |
Is open
Returns true if socket connection is open.
Referenced by close(), flush(), iterator(), setBlocking(), and write().
|
protected |
Referenced by host().
|
protected |
Referenced by port().
|
protected |
|
protected |
Referenced by timeout().
|
protected |