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

close() : void

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::close

end( $arg0 = null) : void

end()

Same as @see \io\vertx\jphp\core\net\NetSocket::end but writes some data to the stream before ending.

param $t [Buffer] end($t)

Arguments

$arg0

Buffer

<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

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

Tell the operating system to stream a file as specified by <code>filename</code> directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files.

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

param $filename [string] file name of the file to send sendFile($filename)

Tell the operating system to stream a file as specified by filename directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files.

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

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 $resultHandler [callable] handler sendFile($filename, $resultHandler)

Tell the operating system to stream a file as specified by filename directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files.

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

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

param $data [Buffer] <b> write($data) </b>

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

Write a \java.lang.String to the connection, encoded in UTF-8.

param $str [string] the string to write write($str)

Write a \java.lang.String to the connection, encoded using the encoding enc.

param $str [string] the string to write param $enc [string] the encoding to use write($str, $enc)

Like 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)

Arguments

$arg0

Buffer | string

$arg1

callable | string

Response

$this

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