NetSocket

Represents a socket-like interface to a TCP connection on either the client or the server side.

Instances of this class are created on the client side by an @see \io\vertx\jphp\core\net\NetClient when a connection to a server is made, or on the server side by a @see \io\vertx\jphp\core\net\NetServer when a server accepts a connection.

It implements both and so it can be used with

see

to pump data with flow control.

package

Default

Methods

__construct

__construct() 

Close the NetSocket and notify the <code>handler</code> when the operation completes.

close( $arg0) : void

Arguments

$arg0

callable

Set a handler that will be called when the NetSocket is closed

closeHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently

drainHandler

drainHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Calls @see \io\vertx\jphp\core\net\NetSocket::end.

end( $arg0,  $arg1 = null) : void

param $handler [callable] end($handler)

Same as but with an handler called when the operation completes

param $data [Buffer] param $handler [callable] end($data, $handler)

Arguments

$arg0

Buffer | callable

$arg1

callable

<p> This handler might be called after the close handler when the socket is paused and there are still buffers to deliver.

endHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

exceptionHandler

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

fetch

fetch( $arg0) : $this

Arguments

$arg0

integer

Response

$this

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Returns the SNI server name presented during the SSL handshake by the client.

indicatedServerName() : string

Response

string

the indicated server name

isSsl

isSsl() : boolean

Response

boolean

true if this {@link io.vertx.core.net.NetSocket} is encrypted via SSL/TLS.

localAddress

localAddress() : \io\vertx\jphp\core\net\SocketAddress

Response

\io\vertx\jphp\core\net\SocketAddress

the local address for this socket

pause

pause() : $this

Response

$this

Pause this stream and return a to transfer the elements of this stream to a destination .

pipe() : \io\vertx\jphp\core\net\Pipe<Buffer>

The stream will be resumed when the pipe will be wired to a WriteStream.

Response

\io\vertx\jphp\core\net\Pipe

a pipe

Pipe this <code>ReadStream</code> to the <code>WriteStream</code>.

pipeTo( $arg0,  $arg1) : void

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Arguments

$arg0

WriteStream

$arg1

callable

remoteAddress

remoteAddress() : \io\vertx\jphp\core\net\SocketAddress

Response

\io\vertx\jphp\core\net\SocketAddress

the remote address for this socket

resume

resume() : $this

Response

$this

Same as @see \io\vertx\jphp\core\net\NetSocket::sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

sendFile( $arg0,  $arg1,  $arg2 = null,  $arg3 = null) : $this

param $filename [string] file name of the file to send param $resultHandler [callable] handler sendFile($filename, $resultHandler)

Same as @see \io\vertx\jphp\core\net\NetSocket::sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

param $filename [string] file name of the file to send param $offset [integer] offset param $resultHandler [callable] handler sendFile($filename, $offset, $resultHandler)

Same as @see \io\vertx\jphp\core\net\NetSocket::sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

param $filename [string] file name of the file to send param $offset [integer] offset param $length [integer] length param $resultHandler [callable] handler sendFile($filename, $offset, $length, $resultHandler)

Arguments

$arg0

string

$arg1

callable | integer

$arg2

callable | integer

$arg3

callable

Response

$this

a reference to this, so the API can be used fluently

setWriteQueueMaxSize

setWriteQueueMaxSize( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.

upgradeToSsl( $arg0,  $arg1 = null) : $this

param $handler [callable] the handler will be notified when it's upgraded upgradeToSsl($handler)

Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.

param $serverName [string] the server name param $handler [callable] the handler will be notified when it's upgraded upgradeToSsl($serverName, $handler)

Arguments

$arg0

callable | string

$arg1

callable

Response

$this

a reference to this, so the API can be used fluently

Same as @see \io\vertx\jphp\core\net\NetSocket::write but with an <code>handler</code> called when the operation completes

write( $arg0,  $arg1,  $arg2 = null) : void

param $str [string] param $handler [callable] write($str, $handler)

Like @see \io\vertx\jphp\core\streams\WriteStream::write but with an handler called when the message has been written or failed to be written.

param $message [Buffer] param $handler [callable] write($message, $handler)

Same as @see \io\vertx\jphp\core\net\NetSocket::write but with an handler called when the operation completes

param $str [string] param $enc [string] param $handler [callable] write($str, $enc, $handler)

Arguments

$arg0

Buffer | string

$arg1

callable | string

$arg2

callable

When a <code>NetSocket</code> is created it automatically registers an event handler with the event bus, the ID of that handler is given by <code>writeHandlerID</code>.

writeHandlerID() : string

Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other connections which are owned by different event loops.

Response

string

the write handler ID

This will return <code>true</code> if there are more bytes in the write queue than the value set using @see \io\vertx\jphp\core\net\NetSocket::setWriteQueueMaxSize

writeQueueFull() : boolean

Response

boolean

true if write queue is full