Class: Bs_SocketClient
Source Location: /core/net/Bs_SocketClient.class.php
Bs_Object
|
--Bs_SocketClient
Generalized SocketClient class.
Author(s):
Version:
- 4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:48:41 $
Copyright:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Class Methods
constructor Bs_SocketClient [line 144]
Bs_SocketClient Bs_SocketClient(
)
|
|
constructor.
method connect [line 285]
mixed connect(
string
$host, int
$port, [bool
$persistent = FALSE], [int
$timeOut = 0], [bool
$blocking = TRUE], [string
$return = 'bool'])
|
|
Connect to the specified port. If called when param $return is set to 'bool' and the socket is already connected, it disconnects and connects again. unless called with param $return='resource', these object vars are overwritten/updated: $this->host $this->_connection $this->port $this->_state $this->timeOut $this->persistent $this->_blocking
Tags:
Parameters:
method disconnect [line 372]
void disconnect(
[resouce
$connection = NULL])
|
|
Disconnects from the peer, closes the socket. if the param $connection is given, this method is used static.
Parameters:
method eof [line 389]
bool eof(
[resouce
$connection = NULL])
|
|
if the param $connection is given, this method is used static.
Parameters:
method getErrorMessage [line 550]
string getErrorMessage(
long
$errCode)
|
|
Return a textual error message for a bs socket error code
Tags:
Parameters:
method gets [line 471]
string gets(
int
$size, [mixed
$connection = NULL])
|
|
Read a specified amount of data, stop when $size is reached, eof or newline. 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. if the param $connection is given, this method is used static.
Tags:
Parameters:
method getState [line 235]
Get the current state of the socket. one of define('BS_SOCKETCLIENT_DISCONNECTED', 0); define('BS_SOCKETCLIENT_CONNECTED', 1); define('BS_SOCKETCLIENT_SENT', 2); define('BS_SOCKETCLIENT_REQUEST_SENT', 3); define('BS_SOCKETCLIENT_GOT_REPLY', 4); define('BS_SOCKETCLIENT_GOT_REPLY_HEADER', 5); define('BS_SOCKETCLIENT_GOT_REPLY_CONTENT', 6); hint. (bool)TRUE=connected, FALSE=disconnected it's possible that this is set to connected but the connection expired or something else happened... it's the "should be" state.
Tags:
method isBlocking [line 210]
Find out if the socket is in blocking mode.
Tags:
method read [line 489]
string read(
int
$size, [mixed
$connection = NULL])
|
|
Read a specified amount of data, stop when $size is reached or eof. continue on a newline. 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. if the param $connection is given, this method is used static.
Tags:
Parameters:
method readAll [line 449]
string readAll(
[resouce
$connection = NULL])
|
|
Read until the socket closes. CAUTION: this method will not exit if the socket is in blocking mode until the socket closes. if the param $connection is given, this method is used static.
Tags:
Parameters:
method readLine [line 408]
mixed readLine(
[bool
$removeCrlf = TRUE], [resouce
$connection = NULL])
|
|
Read from the connection until we got a full line, then return it. if the param $connection is given, this method is used static.
Tags:
Parameters:
method reconnect [line 355]
Reconnect to the current host with the current settings - if possible.
Tags:
method setBlocking [line 171]
bool setBlocking(
[bool
$mode = TRUE], [resouce
$connection = NULL])
|
|
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. note I: nonblocking mode not supported on win (php404). so until it's available, you cannot set this to blocking on win. note II: if the 2nd param $connection is given, this method is used static. the return value stays the same, no need to pass $connection by reference. note III: non-blocking sockets waste alot of cpu. take care. but some things really cannot be done without.
Tags:
Parameters:
method setState [line 257]
void setState(
int
$state)
|
|
Set the current state of the socket. one of define('BS_SOCKETCLIENT_DISCONNECTED', 0); define('BS_SOCKETCLIENT_CONNECTED', 1); define('BS_SOCKETCLIENT_SENT', 2); define('BS_SOCKETCLIENT_REQUEST_SENT', 3); define('BS_SOCKETCLIENT_GOT_REPLY', 4); define('BS_SOCKETCLIENT_GOT_REPLY_HEADER', 5); define('BS_SOCKETCLIENT_GOT_REPLY_CONTENT', 6);
Tags:
Parameters:
method write [line 521]
bool write(
string
$data, [resouce
$connection = NULL])
|
|
Write data to the connection. if the param $connection is given, this method is used static.
Tags:
Parameters:
method writeLine [line 506]
bool writeLine(
string
$line, [string
$crLf = "\r\n"], [resouce
$connection = NULL])
|
|
Write a line to the connection. if the param $connection is given, this method is used static.
Tags:
Parameters:
|
|