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

Class: System_Socket

Source Location: /System_Socket-0.4.0/Socket.php

Class Overview


System_Socket


Author(s):

Version:

  • $Revision: 1.15 $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 62]
System_Socket

The System_Socket class represents a socket resource and aims to provide a thight ad robust API for handling those. Beside that it implements a creator for System_Socket_Connection and System_Socket_Listener. You'd most probably never use this class or an object of it directly, but the creator pattern. However this doesn't mean that you do not need to know about its socket configuration options.

Example: Simple HTTP request to localhost

  1.    require_once 'System/Socket.php';
  2.  
  3.    $conn &System_Socket::createConnection(array('address' => '127.0.0.1'));
  4.    if (PEAR::isError($conn)) {
  5.        die($conn->getMessage());
  6.    }
  7.  
  8.    $conn->writeLine('GET / HTTP/1.0');
  9.    $conn->writeLine('Connection: close');
  10.    $conn->writeLine();
  11.  
  12.    while ($data $conn->read()) {
  13.        echo $data;
  14.    }

  • Author: Michael Wallner <mike@php.net>
  • Version: $Revision: 1.15 $
  • Access: public


[ Top ]


Class Variables

$address =  '127.0.0.1'

[line 112]

Network address (IP) or file path for unix sockets
  • Access: public

Type:   string


[ Top ]

$domain =  AF_INET

[line 84]

Socket domain/family

AF_INET | AF_UNIX

  • Access: public

Type:   int


[ Top ]

$port =  80

[line 120]

Port
  • Access: public

Type:   int


[ Top ]

$proto =  SOL_TCP

[line 104]

Socket layer

SOL_SOCKET | SOL_TCP | SOL_UDP

  • Access: public

Type:   int


[ Top ]

$queueLength =  SOMAXCONN

[line 128]

Queuelength
  • Access: public

Type:   int


[ Top ]

$type =  SOCK_STREAM

[line 94]

Socket type

SOCK_DGRAM | SOCK_RAW | SOCK_RDM | SOCK_SEQPACKET | SOCK_STREAM

  • Access: public

Type:   int


[ Top ]



Method Detail

System_Socket (Constructor)   [line 137]

object System_Socket System_Socket( [int $resource = null])

Constructor
  • Access: public

Parameters:

int   $resource   —  socket resource handle

[ Top ]

accept   [line 246]

mixed accept( )

Accept a socket connection

Accept a socket connection from a prior created socket resource handle.

  • Return: new socket resource handle or false
  • Access: public

[ Top ]

bind   [line 211]

bool bind( )

Bind the socket resource

Bind the socket resource to System_Socket::address at System_Socket::port.

  • Access: public

[ Top ]

close   [line 224]

void close( )

Close the socket

Close the socket resource handle.

  • Access: public

[ Top ]

connect   [line 260]

bool connect( )

Connect the socket

Connect the socket resource handle to System_Socket::address at System_Socket::port.

  • Access: public

[ Top ]

create   [line 190]

bool create( )

Create a socket resource

Create the socket resource with the objects properties as parameters.

  • Access: public

[ Top ]

getBlocking   [line 334]

bool getBlocking( )

Get socket blocking
  • Access: public

[ Top ]

getOption   [line 291]

mixed getOption( string $option, [int $level = SOL_SOCKET])

Get socket option

Retrieve a socket option after you have created the socket resource handle.

  • Access: public

Parameters:

string   $option   — 
int   $level   — 

[ Top ]

getResource   [line 177]

int getResource( )

Get socket resource handle
  • Return: resource handle
  • Access: public

[ Top ]

getStatus   [line 303]

mixed getStatus( [string $part = null])

Get socket status
  • Access: public

Parameters:

string   $part   — 

[ Top ]

hasResource   [line 363]

bool hasResource( )

Check if the we have still a valid socket resource
  • See: System_Socket::isResource()
  • Access: public

[ Top ]

isResource   [line 351]

bool isResource( resource $rsrc)

Check if a resource is still valid

Due to a nasty bug in PHP < 4.3.6 and 5.0.0 is_resource() would return true for a already closed socket, too. So we check the resource type additionally to be really sure we have still a valid socket resource.

  • Access: public

Parameters:

resource   $rsrc   — 

[ Top ]

lastError   [line 165]

object PEAR_Error &lastError( )

Retrieve last socket error

See include/WinSock.h (Win32) and include/sys/errno.h (Un*x) for the values of the error codes. See also (win32|unix)_socket_constants.h located in ext/sockets for all available SOCKET_E* constants.

  • Access: public

[ Top ]

listen   [line 233]

void listen( )

  • Access: public

[ Top ]

setBlocking   [line 316]

bool setBlocking( bool $blocking)

Set socket blocking
  • Access: public

Parameters:

bool   $blocking   — 

[ Top ]

setOption   [line 276]

bool setOption( string $option, mixed $value, [int $level = SOL_SOCKET])

Set socket option

Set a socket option after you have created a socket resource handle.

  • Access: public

Parameters:

string   $option   — 
mixed   $value   — 
int   $level   — 

[ Top ]


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