Net_Socket

Net_Socket --  Generalized Socket class

Description

Socket enables comfortable handling Socket connections.

Net_Socket::connect

mixed Net_Socket::connect (string $addr, integer $port, boolean [$persistent], integer [$timeout])

Connect to the specified port. If called when the socket is already connected, it disconnects and connects again.

Parameter

Returns

Net_Socket::disconnect

mixed Net_Socket::disconnect ()

Disconnects from the peer, closes the socket.

Returns

Net_Socket::isBlocking

boolean Net_Socket::isBlocking ()

Find out if the socket is in blocking mode.

Returns

Net_Socket::setBlocking

void Net_Socket::setBlocking (boolean $mode)

Sets whether the socket connection should be blocking or not. A read call to a non-blocking socket will return immediately if there is no data available, whereas it will block until there is data for blocking sockets.

Warnung

If you use readAll() on a connection in blocking mode, the function will be not terminated until the socket connection will be closed.

Parameter

Net_Socket::setTimeout

mixed Net_Socket::setTimeout (integer $seconds, integer $microseconds)

Sets the timeout value on socket descriptor, expressed in the sum of seconds and microseconds

Parameter

Returns

Net_Socket::getStatus

mixed Net_Socket::getStatus ()

Returns information about an existing socket resource. Currently returns four entries in the result array:

Returns

Net_Socket::gets

mixed Net_Socket::gets (integer $size)

Returns a string containing data from the socket connection

Parameter

Returns

Net_Socket::read

mixed Net_Socket::read (integer $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 getting beforehand, this is definitely the way to go.

Parameter

Returns

Net_Socket::write

mixed Net_Socket::write (string $data)

Write data to a socket connection

Parameter

Returns

Net_Socket::writeLine

mixed Net_Socket::writeLine (string $data)

Write a line of data to a socket connection, followed by a trailing "\r\n".

Parameter

Returns

Net_Socket::eof

boolean Net_Socket::eof ()

fire true if the connection is closed or input stream finished

Returns

Net_Socket::readByte

mixed Net_Socket::readByte ()

Read a byte from the socket stream

Returns

Net_Socket::readWord

mixed Net_Socket::readWord ()

Reads a word from the socket stream Word means a binary word, not a word in a language

Returns

Net_Socket::readInt

mixed Net_Socket::readInt ()

Reads a integer number from the socket stream. The length of a integer is 4 bytes

Returns

Net_Socket::readIPAddress

mixed Net_Socket::readIPAddress ()

Reads a IP from the socket stream The function expect a integer which will converted to a IP address. This function only works with IPv4 addresses.

Returns

Net_Socket::readLine

mixed Net_Socket::readLine ()

Read until either the end of the socket or a newline, whichever comes first. Strips the trailing newline from the returned data.

Returns

Net_Socket::readAll

mixed Net_Socket::readAll ()

Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the socket is in blocking mode until the socket closes.

Returns