DatagramSocket

A datagram socket can be used to send @see \io\vertx\jphp\core\datagram\DatagramPacket's to remote datagram servers and receive @see \io\vertx\jphp\core\datagram\DatagramPackets .

Usually you use a datagram socket to send UDP over the wire. UDP is connection-less which means you are not connected to the remote peer in a persistent way. Because of this you have to supply the address and port of the remote peer when sending data.

You can send data to ipv4 or ipv6 addresses, which also include multicast addresses.

Please consult the documentation for more information on datagram sockets.

package

Default

Methods

__construct

__construct() 

Block the given address for the given multicast address and notifies the once the operation completes.

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

param $multicastAddress [string] the address for which you want to block the source address param $sourceToBlock [string] the source address which should be blocked. You will not receive an multicast packets for it anymore. param $handler [callable] the handler to notify once the operation completes blockMulticastGroup($multicastAddress, $sourceToBlock, $handler)

Block the given address for the given multicast address on the given network interface and notifies the once the operation completes.

param $multicastAddress [string] the address for which you want to block the source address param $networkInterface [string] the network interface on which the blocking should occur. param $sourceToBlock [string] the source address which should be blocked. You will not receive an multicast packets for it anymore. param $handler [callable] the handler to notify once the operation completes blockMulticastGroup($multicastAddress, $networkInterface, $sourceToBlock, $handler)

Arguments

$arg0

string

$arg1

string

$arg2

callable | string

$arg3

callable

Response

$this

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

Closes the @see \io\vertx\jphp\core\datagram\DatagramSocket. The close itself is asynchronous.

close( $arg0 = null) : void

close()

Closes the @see \io\vertx\jphp\core\datagram\DatagramSocket implementation asynchronous and notifies the handler once done.

param $handler [callable] the handler to notify once complete close($handler)

Arguments

$arg0

callable

endHandler

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

Whether the metrics are enabled for this measured object

isMetricsEnabled() : boolean

Response

boolean

{@code true} if metrics are enabled

Start listening on the given port and host. The handler will be called when the socket is listening.

listen( $arg0,  $arg1,  $arg2) : $this

Arguments

$arg0

integer

$arg1

string

$arg2

callable

Response

$this

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

Joins a multicast group and listens for packets send to it.

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

The is notified once the operation completes.

param $multicastAddress [string] the address of the multicast group to join param $handler [callable] then handler to notify once the operation completes listenMulticastGroup($multicastAddress, $handler)

Joins a multicast group and listens for packets send to it on the given network interface. The is notified once the operation completes.

param $multicastAddress [string] the address of the multicast group to join param $networkInterface [string] the network interface on which to listen for packets. param $source [string] the address of the source for which we will listen for multicast packets param $handler [callable] then handler to notify once the operation completes listenMulticastGroup($multicastAddress, $networkInterface, $source, $handler)

Arguments

$arg0

string

$arg1

callable | string

$arg2

string

$arg3

callable

Response

$this

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

Return the @see \io\vertx\jphp\core\net\SocketAddress to which this @see \io\vertx\jphp\core\datagram\DatagramSocket is bound.

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

Response

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

the socket address

pause

pause() : $this

Response

$this

resume

resume() : $this

Response

$this

Write the given @see \io\vertx\jphp\core\buffer\Buffer to the @see \io\vertx\jphp\core\net\SocketAddress.

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

The \io.vertx.core.Handler will be notified once the write completes.

param $packet [Buffer] the \io.vertx.core.buffer.Buffer to write param $port [integer] the host port of the remote peer param $host [string] the host address of the remote peer param $handler [callable] the \io.vertx.core.Handler to notify once the write completes. send($packet, $port, $host, $handler)

Write the given \java.lang.String to the @see \io\vertx\jphp\core\net\SocketAddress using UTF8 encoding. The will be notified once the write completes.

param $str [string] the String to write param $port [integer] the host port of the remote peer param $host [string] the host address of the remote peer param $handler [callable] the \io.vertx.core.Handler to notify once the write completes. send($str, $port, $host, $handler)

Write the given \java.lang.String to the @see \io\vertx\jphp\core\net\SocketAddress using the given encoding. The will be notified once the write completes.

param $str [string] the String to write param $enc [string] the charset used for encoding param $port [integer] the host port of the remote peer param $host [string] the host address of the remote peer param $handler [callable] the \io.vertx.core.Handler to notify once the write completes. send($str, $enc, $port, $host, $handler)

Arguments

$arg0

Buffer | string

$arg1

string | integer

$arg2

string | integer

$arg3

callable | string

$arg4

callable

Response

$this

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

Returns a <code>WriteStream<Buffer></code> able to send to the

sender( $arg0,  $arg1) : \io\vertx\jphp\core\datagram\WriteStream<Buffer>
see \io\vertx\jphp\core\net\SocketAddress.

Arguments

$arg0

integer

$arg1

string

Response

\io\vertx\jphp\core\datagram\WriteStream

the write stream for sending packets

Leaves a multicast group and stops listening for packets send to it.

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

The is notified once the operation completes.

param $multicastAddress [string] the address of the multicast group to leave param $handler [callable] then handler to notify once the operation completes unlistenMulticastGroup($multicastAddress, $handler)

Leaves a multicast group and stops listening for packets send to it on the given network interface. The is notified once the operation completes.

param $multicastAddress [string] the address of the multicast group to join param $networkInterface [string] the network interface on which to listen for packets. param $source [string] the address of the source for which we will listen for multicast packets param $handler [callable] the handler to notify once the operation completes unlistenMulticastGroup($multicastAddress, $networkInterface, $source, $handler)

Arguments

$arg0

string

$arg1

callable | string

$arg2

string

$arg3

callable

Response

$this

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