vertx / io.vertx.reactivex.core.net / NetSocket

NetSocket

open class NetSocket : ReadStream<Buffer>, WriteStream<Buffer>

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 io.vertx.reactivex.core.net.NetClient when a connection to a server is made, or on the server side by a io.vertx.reactivex.core.net.NetServer when a server accepts a connection.

It implements both and so it can be used with io.vertx.reactivex.core.streams.Pump to pump data with flow control.

NOTE: This class has been automatically generated from the io.vertx.core.net.NetSocket non RX-ified interface using Vert.x codegen.

Constructors

<init>

NetSocket(delegate: NetSocket)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<NetSocket>

Functions

close

open fun close(): Unit

Close the NetSocket

closeHandler

open fun closeHandler(handler: Handler<Void>): NetSocket

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

drainHandler

open fun drainHandler(handler: Handler<Void>): NetSocket

end

open fun end(t: Buffer): Unit

Same as io.vertx.reactivex.core.net.NetSocket#end but writes some data to the stream before ending.

open fun end(): Unit

Calls io.vertx.reactivex.core.net.NetSocket#close

endHandler

open fun endHandler(endHandler: Handler<Void>): NetSocket

equals

open fun equals(other: Any?): Boolean

exceptionHandler

open fun exceptionHandler(handler: Handler<Throwable>): NetSocket

getDelegate

open fun getDelegate(): NetSocket

handler

open fun handler(handler: Handler<Buffer>): NetSocket

hashCode

open fun hashCode(): Int

indicatedServerName

open fun indicatedServerName(): String

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

isSsl

open fun isSsl(): Boolean

localAddress

open fun localAddress(): SocketAddress

newInstance

open static fun newInstance(arg: NetSocket): NetSocket

pause

open fun pause(): NetSocket

remoteAddress

open fun remoteAddress(): SocketAddress

resume

open fun resume(): NetSocket

rxSendFile

open fun rxSendFile(filename: String): Completable
open fun rxSendFile(filename: String, offset: Long): Completable
open fun rxSendFile(filename: String, offset: Long, length: Long): Completable

Same as io.vertx.reactivex.core.net.NetSocket#sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

sendFile

open fun sendFile(filename: String): NetSocket
open fun sendFile(filename: String, offset: Long): NetSocket
open fun sendFile(filename: String, offset: Long, length: Long): NetSocket

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.

open fun sendFile(filename: String, resultHandler: Handler<AsyncResult<Void>>): NetSocket
open fun sendFile(filename: String, offset: Long, resultHandler: Handler<AsyncResult<Void>>): NetSocket
open fun sendFile(filename: String, offset: Long, length: Long, resultHandler: Handler<AsyncResult<Void>>): NetSocket

Same as io.vertx.reactivex.core.net.NetSocket#sendFile but also takes a handler that will be called when the send has completed or a failure has occurred

setWriteQueueMaxSize

open fun setWriteQueueMaxSize(maxSize: Int): NetSocket

toFlowable

open fun toFlowable(): Flowable<Buffer>

toObservable

open fun toObservable(): Observable<Buffer>

toString

open fun toString(): String

upgradeToSsl

open fun upgradeToSsl(handler: Handler<Void>): NetSocket
open fun upgradeToSsl(serverName: String, handler: Handler<Void>): NetSocket

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

write

open fun write(data: Buffer): NetSocketopen fun write(str: String): NetSocket

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

open fun write(str: String, enc: String): NetSocket

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

writeHandlerID

open fun writeHandlerID(): String

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

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.

writeQueueFull

open fun writeQueueFull(): Boolean

This will return true if there are more bytes in the write queue than the value set using io.vertx.reactivex.core.net.NetSocket#setWriteQueueMaxSize