phpDocumentor PEAR
[ class tree: PEAR ] [ index: PEAR ] [ all elements ]

Class: Net_Socket

Source Location: /modules/Apps/MailClient/PEAR/Net/Socket.php

Class Net_Socket

Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From PEAR

PEAR::PEAR()
Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.
PEAR::delExpect()
This method deletes all occurences of the specified element from the expected error codes stack.
PEAR::expectError()
This method is used to tell which errors you expect to get.
PEAR::getStaticProperty()
If you have a class that's mostly/entirely static, and you need static
PEAR::isError()
Tell whether a value is a PEAR error.
PEAR::loadExtension()
OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.
PEAR::popErrorHandling()
Pop the last error handler used
PEAR::popExpect()
This method pops one element off the expected error codes stack.
PEAR::pushErrorHandling()
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.
PEAR::raiseError()
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.
PEAR::registerShutdownFunc()
Use this function to register a shutdown method for static classes.
PEAR::setErrorHandling()
Sets how errors generated by this object should be handled.
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::throwError()
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::_PEAR()
Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

[ Top ]
Property Summary
string   $addr   The IP address to connect to.
boolean   $blocking   Whether the socket is blocking. Defaults to true.
resource   $fp   Socket file pointer.
integer   $lineLength   Number of bytes to read at a time in readLine() and readAll(). Defaults to 2048.
boolean   $persistent   Whether the socket is persistent. Defaults to false.
integer   $port   The port number to connect to.
integer   $timeout   Number of seconds to wait on socket connections before assuming there's no more data. Defaults to no timeout.

[ Top ]
Method Summary
boolean   connect()   Connect to the specified port. If called when the socket is already connected, it disconnects and connects again.
mixed   disconnect()   Disconnects from the peer, closes the socket.
false   enableCrypto()   Turns encryption on/off on a connected socket.
bool   eof()   Tests for end-of-file on a socket descriptor.
$size   gets()   Get a specified line of data
mixed   getStatus()   Returns information about an existing socket resource.
boolean   isBlocking()   Find out if the socket is in blocking mode.
$size   read()   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.
string   readAll()   Read until the socket closes, or until there is no more data in
1   readByte()   Reads a byte of data
integer   readInt()   Reads an int of data
Dot   readIPAddress()   Reads an IP Address and returns it in a dot formated string
All   readLine()   Read until either the end of the socket or a newline, whichever comes first. Strips the trailing newline from the returned data.
string,   readString()   Reads a zero-terminated string of data
1   readWord()   Reads a word of data
False   select()   Runs the equivalent of the select() system call on the socket with a timeout specified by tv_sec and tv_usec.
mixed   setBlocking()   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.
mixed   setTimeout()   Sets the timeout value on socket descriptor, expressed in the sum of seconds and microseconds
mixed   setWriteBuffer()   Sets the file buffering size on the stream.
mixed   write()   Write a specified amount of data.
mixed   writeLine()   Write a line of data to the socket, followed by a trailing "\r\n".

[ Top ]
Properties
string   $addr = '' [line 59]

The IP address to connect to.


[ Top ]
boolean   $blocking = true [line 47]

Whether the socket is blocking. Defaults to true.


[ Top ]
resource   $fp = null [line 41]

Socket file pointer.


[ Top ]
integer   $lineLength = 2048 [line 79]

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


[ Top ]
boolean   $persistent = false [line 53]

Whether the socket is persistent. Defaults to false.


[ Top ]
integer   $port = 0 [line 65]

The port number to connect to.


[ Top ]
integer   $timeout = false [line 72]

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


[ Top ]
Methods
connect  [line 97]

  boolean connect( string $addr, [integer $port = 0], [boolean $persistent = null], [integer $timeout = null], [array $options = null]  )

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

Parameters:
string   $addr:  IP address or host name.
integer   $port:  TCP port number.
boolean   $persistent:  (optional) Whether the connection is persistent (kept open between requests by the web server).
integer   $timeout:  (optional) How long to wait for data.
array   $options:  See options for stream_context_create.

API Tags:
Return:  | PEAR_Error True on success or a PEAR_Error on failure.
Access:  public


[ Top ]
disconnect  [line 157]

  mixed disconnect( )

Disconnects from the peer, closes the socket.


API Tags:
Return:  true on success or an error object otherwise
Access:  public


[ Top ]
enableCrypto  [line 564]

  false enableCrypto( bool $enabled, integer $type  )

Turns encryption on/off on a connected socket.

Parameters:
bool   $enabled:  Set this parameter to true to enable encryption and false to disable encryption.
integer   $type:  Type of encryption. See http://se.php.net/manual/en/function.stream-socket-enable-crypto.php for values.

API Tags:
Return:  on error, true on success and 0 if there isn't enough data and the user should try again (non-blocking sockets only). A PEAR_Error object is returned if the socket is not connected
Access:  public


[ Top ]
eof  [line 358]

  bool eof( )

Tests for end-of-file on a socket descriptor.

Also returns true if the socket is disconnected.


API Tags:
Access:  public


[ Top ]
gets  [line 269]

  $size gets( $size  )

Get a specified line of data

Parameters:
   $size: 

API Tags:
Return:  bytes of data from the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
getStatus  [line 253]

  mixed getStatus( )

Returns information about an existing socket resource.

Currently returns four entries in the result array:

<p> timed_out (bool) - The socket timed out waiting for data
blocked (bool) - The socket was blocked
eof (bool) - Indicates EOF event
unread_bytes (int) - Number of bytes left in the socket buffer
</p>


API Tags:
Return:  Array containing information about existing socket resource or an error object otherwise
Access:  public


[ Top ]
isBlocking  [line 174]

  boolean isBlocking( )

Find out if the socket is in blocking mode.


API Tags:
Return:  The current blocking mode.
Access:  public


[ Top ]
read  [line 289]

  $size 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.

Parameters:
integer   $size:  The number of bytes to read from the socket.

API Tags:
Return:  bytes of data from the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readAll  [line 491]

  string readAll( )

Read until the socket closes, or until there is no more data in

the inner PHP buffer. If the inner buffer is empty, in blocking mode we wait for at least 1 byte of data. Therefore, in blocking mode, if there is no data at all to be read, this function will never exit (unless the socket is closed on the remote end).


API Tags:
Return:  All data until the socket closes, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readByte  [line 370]

  1 readByte( )

Reads a byte of data


API Tags:
Return:  byte of data from the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readInt  [line 403]

  integer readInt( )

Reads an int of data


API Tags:
Return:  1 int of data from the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readIPAddress  [line 441]

  Dot readIPAddress( )

Reads an IP Address and returns it in a dot formated string


API Tags:
Return:  formated string, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readLine  [line 461]

  All readLine( )

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


API Tags:
Return:  available data up to a newline, without that newline, or until the end of the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
readString  [line 421]

  string, readString( )

Reads a zero-terminated string of data


API Tags:
Return:  or a PEAR_Error if not connected.
Access:  public


[ Top ]
readWord  [line 386]

  1 readWord( )

Reads a word of data


API Tags:
Return:  word of data from the socket, or a PEAR_Error if not connected.
Access:  public


[ Top ]
select  [line 516]

  False select( integer $state, integer $tv_sec, [integer $tv_usec = 0]  )

Runs the equivalent of the select() system call on the socket with a timeout specified by tv_sec and tv_usec.

Parameters:
integer   $state:  Which of read/write/error to check for.
integer   $tv_sec:  Number of seconds for timeout.
integer   $tv_usec:  Number of microseconds for timeout.

API Tags:
Return:  if select fails, integer describing which of read/write/error are ready, or PEAR_Error if not connected.
Access:  public


[ Top ]
setBlocking  [line 189]

  mixed 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.

Parameters:
boolean   $mode:  True for blocking sockets, false for nonblocking.

API Tags:
Return:  true on success or an error object otherwise
Access:  public


[ Top ]
setTimeout  [line 209]

  mixed setTimeout( integer $seconds, integer $microseconds  )

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

Parameters:
integer   $seconds:  Seconds.
integer   $microseconds:  Microseconds.

API Tags:
Return:  true on success or an error object otherwise
Access:  public


[ Top ]
setWriteBuffer  [line 226]

  mixed setWriteBuffer( integer $size  )

Sets the file buffering size on the stream.

See php's stream_set_write_buffer for more information.

Parameters:
integer   $size:  Write buffer size.

API Tags:
Return:  on success or an PEAR_Error object otherwise
Access:  public


[ Top ]
write  [line 308]

  mixed write( string $data, [integer $blocksize = null]  )

Write a specified amount of data.

Parameters:
string   $data:  Data to write.
integer   $blocksize:  Amount of data to write at once. NULL means all at once.

API Tags:
Return:  true on success or an error object otherwise
Access:  public


[ Top ]
writeLine  [line 341]

  mixed writeLine( $data  )

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

Parameters:
   $data: 

API Tags:
Return:  fputs result, or an error
Access:  public


[ Top ]

Documentation generated on Fri, 26 Dec 2008 21:46:27 -0500 by phpDocumentor 1.4.2