[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/vtlib/thirdparty/network/Net/ -> Socket.php (summary)

(no description)

File Size: 592 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Net_Socket:: (21 methods):
  connect()
  disconnect()
  isBlocking()
  setBlocking()
  setTimeout()
  setWriteBuffer()
  getStatus()
  gets()
  read()
  write()
  writeLine()
  eof()
  readByte()
  readWord()
  readInt()
  readString()
  readIPAddress()
  readLine()
  readAll()
  select()
  enableCrypto()


Class: Net_Socket  - X-Ref

Generalized Socket class.

connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null)   X-Ref
Connect to the specified port. If called when the socket is
already connected, it disconnects and connects again.

param: string  $addr        IP address or host name.
param: integer $port        TCP port number.
param: boolean $persistent  (optional) Whether the connection is
param: integer $timeout     (optional) How long to wait for data.
param: array   $options     See options for stream_context_create.
return: boolean | PEAR_Error  True on success or a PEAR_Error on failure.

disconnect()   X-Ref
Disconnects from the peer, closes the socket.

return: mixed true on success or a PEAR_Error instance otherwise

isBlocking()   X-Ref
Find out if the socket is in blocking mode.

return: boolean  The current blocking mode.

setBlocking($mode)   X-Ref
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.

param: boolean $mode  True for blocking sockets, false for nonblocking.
return: mixed true on success or a PEAR_Error instance otherwise

setTimeout($seconds, $microseconds)   X-Ref
Sets the timeout value on socket descriptor,
expressed in the sum of seconds and microseconds

param: integer $seconds  Seconds.
param: integer $microseconds  Microseconds.
return: mixed true on success or a PEAR_Error instance otherwise

setWriteBuffer($size)   X-Ref
Sets the file buffering size on the stream.
See php's stream_set_write_buffer for more information.

param: integer $size     Write buffer size.
return: mixed on success or an PEAR_Error object otherwise

getStatus()   X-Ref
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<br>
blocked (bool) - The socket was blocked<br>
eof (bool) - Indicates EOF event<br>
unread_bytes (int) - Number of bytes left in the socket buffer<br>
</p>

return: mixed Array containing information about existing socket resource or a PEAR_Error instance otherwise

gets($size)   X-Ref
Get a specified line of data

return: $size bytes of data from the socket, or a PEAR_Error if

read($size)   X-Ref
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.

param: integer $size  The number of bytes to read from the socket.
return: $size bytes of data from the socket, or a PEAR_Error if

write($data, $blocksize = null)   X-Ref
Write a specified amount of data.

param: string  $data       Data to write.
param: integer $blocksize  Amount of data to write at once.
return: mixed If the socket is not connected, returns an instance of PEAR_Error

writeLine($data)   X-Ref
Write a line of data to the socket, followed by a trailing "\r\n".

return: mixed fputs result, or an error

eof()   X-Ref
Tests for end-of-file on a socket descriptor.

Also returns true if the socket is disconnected.

return: bool

readByte()   X-Ref
Reads a byte of data

return: 1 byte of data from the socket, or a PEAR_Error if

readWord()   X-Ref
Reads a word of data

return: 1 word of data from the socket, or a PEAR_Error if

readInt()   X-Ref
Reads an int of data

return: integer  1 int of data from the socket, or a PEAR_Error if

readString()   X-Ref
Reads a zero-terminated string of data

return: string, or a PEAR_Error if

readIPAddress()   X-Ref
Reads an IP Address and returns it in a dot formatted string

return: Dot formatted string, or a PEAR_Error if

readLine()   X-Ref
Read until either the end of the socket or a newline, whichever
comes first. Strips the trailing newline from the returned data.

return: All available data up to a newline, without that

readAll()   X-Ref
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).

return: string  All data until the socket closes, or a PEAR_Error if

select($state, $tv_sec, $tv_usec = 0)   X-Ref
Runs the equivalent of the select() system call on the socket
with a timeout specified by tv_sec and tv_usec.

param: integer $state    Which of read/write/error to check for.
param: integer $tv_sec   Number of seconds for timeout.
param: integer $tv_usec  Number of microseconds for timeout.
return: False if select fails, integer describing which of read/write/error

enableCrypto($enabled, $type)   X-Ref
Turns encryption on/off on a connected socket.

param: bool    $enabled  Set this parameter to true to enable encryption
param: integer $type     Type of encryption. See
return: false on error, true on success and 0 if there isn't enough data and the



Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1