Public Method Details |
Net_Socket |
public void Net_Socket( )
|
|
Constructs a new Net_Socket object.
|
Returns |
void |
|
connect |
public mixed connect( string $addr, int $port, [ boolean $persistent, boolean $timeout ] )
|
|
Connect to the specified port. If called when the socket is
already connected, it disconnects and connects again.
|
Parameter |
|
string |
$addr |
|
|
address or host name |
|
|
|
|
boolean |
$persistent |
= >>false<< |
|
(optional) whether the connection is
persistent (kept open between requests by the web server) |
|
|
boolean |
$timeout |
= >>false<< |
|
(optional) how long to wait for data |
|
Returns |
mixed true on success or error object |
|
disconnect |
public mixed disconnect( )
|
|
Disconnects from the peer, closes the socket.
|
Returns |
mixed true on success or an error object otherwise |
|
isBlocking |
public bool isBlocking( )
|
|
Find out if the socket is in blocking mode.
|
Returns |
bool the current blocking mode. |
|
setBlocking |
public void setBlocking( bool $mode )
|
|
Sets whether the socket connection should be blocking or
not. A read call to a non-blocking socket will return immediatelyif there is no data available, whereas it will block until thereis data for blocking sockets.
|
Parameter |
|
bool |
$mode |
|
|
for blocking sockets, false for nonblocking |
|
Returns |
void |
|
read |
public void read( $size )
|
|
Read a specified amount of data. This is guaranteed to return,
and has the added benefit of getting everything in one fread()chunk; if you know the size of the data you're gettingbeforehand, this is definitely the way to go.
|
Parameter |
|
|
$size |
|
|
Warning: documentation is missing. |
|
Returns |
void |
|
writeLine |
public mixed writeLine( $data )
|
|
Write a line of data to the socket, followed by a trailing "\r\n".
|
Parameter |
|
|
$data |
|
|
Warning: documentation is missing. |
|
Returns |
mixed fputs result, or an error |
|
readLine |
public void readLine( )
|
|
Read until either the end of the socket or a newline, whichever
comes first. Strips the trailing newline from the returned data.
|
Returns |
void |
|
readAll |
public void readAll( )
|
|
Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the
socket is in blocking mode until the socket closes.
|
Returns |
void |
|