\Thrift\TransportTSocket

Sockets implementation of the TTransport interface.

Summary

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

Properties

$host_

$host_ : string

Remote hostname

Type

string

$port_

$port_ : integer

Remote port

Type

integer

$persist_

$persist_ : boolean

Persistent socket or plain?

Type

boolean

$debug_

$debug_ : boolean

Debugging on?

Type

boolean

$debugHandler_

$debugHandler_ : mixed

Debug handler

Type

mixed

$handle_

$handle_ : resource

Handle to PHP socket

Type

resource

$sendTimeoutSec_

$sendTimeoutSec_ : integer

Send timeout in seconds.

Combined with sendTimeoutUsec this is used for send timeouts.

Type

integer

$sendTimeoutUsec_

$sendTimeoutUsec_ : integer

Send timeout in microseconds.

Combined with sendTimeoutSec this is used for send timeouts.

Type

integer

$recvTimeoutSec_

$recvTimeoutSec_ : integer

Recv timeout in seconds

Combined with recvTimeoutUsec this is used for recv timeouts.

Type

integer

$recvTimeoutUsec_

$recvTimeoutUsec_ : integer

Recv timeout in microseconds

Combined with recvTimeoutSec this is used for recv timeouts.

Type

integer

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 at most $len bytes.

This method will not wait for all the requested data, it will return as soon as any data is received.

Parameters

integer $len

Maximum number of bytes to read.

Returns

string —

Binary data

readAll()

readAll(  $len) : string

Guarantees that the full amount of data is read.

Parameters

$len

Throws

\Thrift\Transport\TTransportException

if cannot read data

Returns

string —

The data, of exact length

write()

write(string  $buf) 

Write to the socket.

Parameters

string $buf

The data to write

flush()

flush() 

Flush output to the socket.

Since read(), readAll() and write() operate on the sockets directly, this is a no-op

If you wish to have flushable buffering behaviour, wrap this TSocket in a TBufferedTransport.

__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

setHandle()

setHandle(resource  $handle) : void

Parameters

resource $handle

setSendTimeout()

setSendTimeout(integer  $timeout) 

Sets the send timeout.

Parameters

integer $timeout

Timeout in milliseconds.

setRecvTimeout()

setRecvTimeout(integer  $timeout) 

Sets the receive timeout.

Parameters

integer $timeout

Timeout in milliseconds.

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