Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /home/cch/www/pear/Net/Socket.php
PEAR Repository -

Net_Socket

PEAR
   |
  +-- Net_Socket

Generalized Socket class. More docs to be written.

 

private class Net_Socket extends PEAR

Generalized Socket class. More docs to be written.

AuthorsStig Bakken <ssb@fast.no>, Chuck Hagenbuch <chuck@horde.org>
SincePHP 4.0.2
Version0.2

 

Methods inherited from PEAR

pear, _pear, iserror, pear_error, getmode, getcallback, getmessage, getcode, gettype, getdebuginfo, tostring, _pear_call_destructors

Public Method Summary

void

Net_Socket()

Constructs a new Net_Socket object.
mixed

connect(string $addr, int $port, [ boolean $persistent, boolean $timeout ])

Connect to the specified port. If called when the socket is
mixed

disconnect()

Disconnects from the peer, closes the socket.
bool

isBlocking()

Find out if the socket is in blocking mode.
void

setBlocking(bool $mode)

Sets whether the socket connection should be blocking or
void

read( $size)

Read a specified amount of data. This is guaranteed to return,
mixed

writeLine( $data)

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

readLine()

Read until either the end of the socket or a newline, whichever
void

readAll()

Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the

Private Method Summary

void

gets( $size)

void

write( $data)

void

eof()

void

readByte()

void

readWord()

void

readInt()

void

readString()

void

readIPAddress()

Fields inherited from PEAR

$_debug, $error_message_prefix, $error_prepend, $error_append, $mode, $level, $code, $message, $debuginfo, $file, $line

Private Field Summary

string

$fp

Socket file pointer. *
boolean

$blocking

Whether the socket is blocking. *
unknown

$persistent

Whether the socket is persistant. *
string

$addr

The IP address to connect to. *
integer

$port

The port number to connect to. *
boolean

$timeout

Number of seconds to wait on socket connections before
assuming there's no more data. *
integer

$lineLength

Number of bytes to read at a time in readLine() and
readAll(). *

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
IP address or host name
int $port
TCP port number
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 immediately
if there is no data available, whereas it will block until there
is data for blocking sockets.

Parameter
bool $mode
true 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 getting
beforehand, this is definitely the way to go.

Parameter
$size
Returns void


writeLine

public mixed writeLine( $data )

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

Parameter
$data
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


Private Method Details

gets

private void gets( $size )

 

Parameter
$size
Returns void


write

private void write( $data )

 

Parameter
$data
Returns void


eof

private void eof( )

 

Returns void


readByte

private void readByte( )

 

Returns void


readWord

private void readWord( )

 

Returns void


readInt

private void readInt( )

 

Returns void


readString

private void readString( )

 

Returns void


readIPAddress

private void readIPAddress( )

 

Returns void


Private Field Details

$fp

private string $fp

>>null<<


$blocking

private boolean $blocking

>>true<<


$persistent

private unknown $persistent

>>unknown<<


$addr

private string $addr

>>''<<


$port

private integer $port

>><<


$timeout

private boolean $timeout

>>false<<


$lineLength

private integer $lineLength

>>2048<<



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta