apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: Net_Socket

Source Location: /Net_Socket-1.0.2/Socket.php

Class Overview

PEAR
   |
   --Net_Socket

Generalized Socket class. More docs to be written.


Author(s):

Version:

  • 1.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 32]
Generalized Socket class. More docs to be written.


[ Top ]


Class Variables

$addr =  ''

[line 45]

The IP address to connect to.

Type:   mixed


[ Top ]

$blocking =  true

[line 39]

Whether the socket is blocking.

Type:   mixed


[ Top ]

$fp =  null

[line 36]

Socket file pointer.

Type:   mixed


[ Top ]

$lineLength =  2048

[line 56]

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

Type:   mixed


[ Top ]

$persistent =  false

[line 42]

Whether the socket is persistent.

Type:   mixed


[ Top ]

$port =  0

[line 48]

The port number to connect to.

Type:   mixed


[ Top ]

$timeout =  false

[line 52]

Number of seconds to wait on socket connections before

Type:   mixed


[ Top ]



Method Detail

Net_Socket (Constructor)   [line 65]

Net_Socket Net_Socket( )

Constructs a new Net_Socket object.
  • Access: public

[ Top ]

connect   [line 85]

mixed connect( $addr $addr, $port $port, [$persistent $persistent = null], [$timeout $timeout = null], [$options $options = null])

Connect to the specified port. If called when the socket is already connected, it disconnects and connects again.
  • Return: true on success or error object
  • Access: public

Parameters:

$addr   $addr   —  string IP address or host name
$port   $port   —  int TCP port number
$persistent   $persistent   —  bool (optional) whether the connection is persistent (kept open between requests by the web server)
$timeout   $timeout   —  int (optional) how long to wait for data
$options   $options   —  array see options for stream_context_create

[ Top ]

disconnect   [line 140]

mixed disconnect( )

Disconnects from the peer, closes the socket.
  • Return: true on success or an error object otherwise
  • Access: public

[ Top ]

eof   [line 307]

bool eof( )

Tests for end-of-file on a socket descriptor
  • Access: public

[ Top ]

gets   [line 238]

$size gets( $size)

Get a specified line of data
  • Return: bytes of data from the socket, or a PEAR_Error if not connected.
  • Access: public

Parameters:

   $size   — 

[ Top ]

getStatus   [line 221]

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>

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

[ Top ]

isBlocking   [line 158]

bool isBlocking( )

Find out if the socket is in blocking mode.
  • Return: the current blocking mode.
  • Access: public

[ Top ]

read   [line 259]

$size read( $size $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.
  • Return: bytes of data from the socket, or a PEAR_Error if not connected.
  • Access: public

Parameters:

$size   $size   —  The number of bytes to read from the socket.

[ Top ]

readAll   [line 444]

All readAll( )

Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the socket is in blocking mode until the socket closes.
  • Return: data until the socket closes, or a PEAR_Error if not connected.
  • Access: public

[ Top ]

readByte   [line 321]

1 readByte( )

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

[ Top ]

readInt   [line 356]

1 readInt( )

Reads an int of data
  • Return: int of data from the socket, or a PEAR_Error if not connected.
  • Access: public

[ Top ]

readIPAddress   [line 396]

Dot readIPAddress( )

Reads an IP Address and returns it in a dot formated string
  • Return: formated string, or a PEAR_Error if not connected.
  • Access: public

[ Top ]

readLine   [line 417]

All readLine( )

Read until either the end of the socket or a newline, whichever comes first. Strips the trailing newline from the returned data.
  • 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 375]

string, readString( )

Reads a zeroterminated string of data
  • Return: or a PEAR_Error if not connected.
  • Access: public

[ Top ]

readWord   [line 338]

1 readWord( )

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

[ Top ]

setBlocking   [line 175]

mixed setBlocking( $mode $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.
  • Return: true on success or an error object otherwise
  • Access: public

Parameters:

$mode   $mode   —  bool true for blocking sockets, false for nonblocking

[ Top ]

setTimeout   [line 196]

mixed setTimeout( $seconds $seconds, $microseconds $microseconds)

Sets the timeout value on socket descriptor, expressed in the sum of seconds and microseconds
  • Return: true on success or an error object otherwise
  • Access: public

Parameters:

$seconds   $seconds   —  int seconds
$microseconds   $microseconds   —  int microseconds

[ Top ]

write   [line 275]

mixed write( $data)

Write a specified amount of data.
  • Return: true on success or an error object otherwise
  • Access: public

Parameters:

   $data   — 

[ Top ]

writeLine   [line 291]

mixed writeLine( $data)

Write a line of data to the socket, followed by a trailing "\r\n".
  • Return: fputs result, or an error
  • Access: public

Parameters:

   $data   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:15:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.