\TSocket

Sockets implementation of the TTransport interface.

Summary

Methods
Properties
Constants
isOpen()
open()
close()
read()
readAll()
write()
flush()
__construct()
setSendTimeout()
setRecvTimeout()
setDebug()
getHost()
getPort()
No public properties found
No constants found
No protected methods found
$host_
$port_
$debug_
$debugHandler_
N/A
No private methods found
$handle_
$sendTimeout_
$recvTimeout_
$sendTimeoutSet_
$persist_
N/A

Properties

$host_

$host_ : string

Remote hostname

Type

string

$port_

$port_ : integer

Remote port

Type

integer

$debug_

$debug_ : boolean

Debugging on?

Type

boolean

$debugHandler_

$debugHandler_ : mixed

Debug handler

Type

mixed

$handle_

$handle_ : resource

Handle to PHP socket

Type

resource

$sendTimeout_

$sendTimeout_ : integer

Send timeout in milliseconds

Type

integer

$recvTimeout_

$recvTimeout_ : integer

Recv timeout in milliseconds

Type

integer

$sendTimeoutSet_

$sendTimeoutSet_ : boolean

Is send timeout set?

Type

boolean

$persist_

$persist_ : boolean

Persistent socket or plain?

Type

boolean

Methods

isOpen()

isOpen() : boolean

Tests whether this is open

Returns

boolean —

true if the socket is open

open()

open() 

Connects the socket.

close()

close() 

Closes the socket.

read()

read(integer  $len) : string

Read from the socket

Parameters

integer $len

How many bytes

Returns

string —

Binary data

readAll()

readAll(integer  $len) : string

Uses stream get contents to do the reading

Parameters

integer $len

How many bytes

Returns

string —

Binary data

write()

write(string  $buf) 

Write to the socket.

Parameters

string $buf

The data to write

flush()

flush() 

Flush output to the socket.

__construct()

__construct(string  $host = 'localhost', integer  $port = 9090, boolean  $persist = FALSE, string  $debugHandler = null) 

Socket constructor

Parameters

string $host

Remote hostname

integer $port

Remote port

boolean $persist

Whether to use a persistent socket

string $debugHandler

Function to call for error logging

setSendTimeout()

setSendTimeout(integer  $timeout) 

Sets the send timeout.

Parameters

integer $timeout

setRecvTimeout()

setRecvTimeout(integer  $timeout) 

Sets the receive timeout.

Parameters

integer $timeout

setDebug()

setDebug(boolean  $debug) 

Sets debugging output on or off

Parameters

boolean $debug

getHost()

getHost() : string

Get the host that this socket is connected to

Returns

string —

host

getPort()

getPort() : integer

Get the remote port that this socket is connected to

Returns

integer —

port