Class NetSocket
- All Implemented Interfaces:
MutinyDelegate
,ReadStream<Buffer>
,StreamBase
,WriteStream<Buffer>
Instances of this class are created on the client side by an NetClient
when a connection to a server is made, or on the server side by a NetServer
when a server accepts a connection.
It implements both and so it can be used with
Pipe
to pipe data with flow control.
original
non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>
close()
Close the NetSocket and notify thehandler
when the operation completes.Blocking variant ofclose()
.void
Variant ofclose()
that ignores the result of the operation.closeHandler
(Runnable handler) drainHandler
(Runnable handler) io.smallrye.mutiny.Uni<Void>
end()
io.smallrye.mutiny.Uni<Void>
Same as but with anhandler
called when the operation completesBlocking variant ofWriteStream.end()
.endAndAwait
(Buffer data) Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
.void
Variant ofWriteStream.end()
that ignores the result of the operation.void
endAndForget
(Buffer data) Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.endHandler
(Runnable endHandler) boolean
exceptionHandler
(Consumer<Throwable> handler) fetch
(long amount) io.vertx.core.net.NetSocket
int
hashCode()
boolean
isSsl()
localAddress
(boolean real) static NetSocket
newInstance
(io.vertx.core.net.NetSocket arg) pause()
pipe()
io.smallrye.mutiny.Uni<Void>
pipeTo
(WriteStream<Buffer> dst) Pipe thisReadStream
to theWriteStream
.pipeToAndAwait
(WriteStream<Buffer> dst) Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.void
pipeToAndForget
(WriteStream<Buffer> dst) Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.remoteAddress
(boolean real) resume()
io.smallrye.mutiny.Uni<Void>
Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredio.smallrye.mutiny.Uni<Void>
Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredio.smallrye.mutiny.Uni<Void>
Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredsendFileAndAwait
(String filename) Blocking variant ofsendFile(String)
.sendFileAndAwait
(String filename, long offset) Blocking variant ofsendFile(String,long)
.sendFileAndAwait
(String filename, long offset, long length) Blocking variant ofsendFile(String,long,long)
.sendFileAndForget
(String filename) Variant ofsendFile(String)
that ignores the result of the operation.sendFileAndForget
(String filename, long offset) Variant ofsendFile(String,long)
that ignores the result of the operation.sendFileAndForget
(String filename, long offset, long length) Variant ofsendFile(String,long,long)
that ignores the result of the operation.setWriteQueueMaxSize
(int maxSize) io.smallrye.mutiny.Multi<Buffer>
toMulti()
toString()
io.smallrye.mutiny.Uni<Void>
Upgrade channel to use SSL/TLS.io.smallrye.mutiny.Uni<Void>
upgradeToSsl
(String serverName) Upgrade channel to use SSL/TLS.Blocking variant ofupgradeToSsl()
.upgradeToSslAndAwait
(String serverName) Blocking variant ofupgradeToSsl(String)
.Variant ofupgradeToSsl()
that ignores the result of the operation.upgradeToSslAndForget
(String serverName) Variant ofupgradeToSsl(String)
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
LikeWriteStream.write(T)
but with anhandler
called when the message has been written or failed to be written.io.smallrye.mutiny.Uni<Void>
Same aswrite(java.lang.String)
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same aswrite(java.lang.String)
but with anhandler
called when the operation completeswriteAndAwait
(Buffer message) Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
.writeAndAwait
(String str) Blocking variant ofwrite(String)
.writeAndAwait
(String str, String enc) Blocking variant ofwrite(String,String)
.void
writeAndForget
(Buffer message) Variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.void
writeAndForget
(String str) Variant ofwrite(String)
that ignores the result of the operation.void
writeAndForget
(String str, String enc) Variant ofwrite(String,String)
that ignores the result of the operation.boolean
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
NetSocket
public NetSocket(io.vertx.core.net.NetSocket delegate) -
NetSocket
-
-
Method Details
-
getDelegate
public io.vertx.core.net.NetSocket getDelegate()- Specified by:
getDelegate
in interfaceMutinyDelegate
- Specified by:
getDelegate
in interfaceReadStream<Buffer>
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in interfaceWriteStream<Buffer>
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
toSubscriber
-
end
Same as but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
end
in interfaceWriteStream<Buffer>
- Parameters:
data
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwait
in interfaceWriteStream<Buffer>
- Parameters:
data
-- Returns:
- the Void instance produced by the operation.
-
endAndForget
Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<Buffer>
- Parameters:
data
-
-
writeQueueFull
public boolean writeQueueFull()- Specified by:
writeQueueFull
in interfaceWriteStream<Buffer>
- Returns:
true
if write queue is full
-
pipe
- Specified by:
pipe
in interfaceReadStream<Buffer>
- Returns:
- a pipe
-
pipeTo
Pipe thisReadStream
to theWriteStream
.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.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
pipeTo
in interfaceReadStream<Buffer>
- Parameters:
dst
- the destination write stream- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
pipeToAndAwait
in interfaceReadStream<Buffer>
- Parameters:
dst
- the destination write stream- Returns:
- the Void instance produced by the operation.
-
pipeToAndForget
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.This method subscribes on the result of
ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
but you don't need to compose it with other operations.- Specified by:
pipeToAndForget
in interfaceReadStream<Buffer>
- Parameters:
dst
- the destination write stream
-
exceptionHandler
- Specified by:
exceptionHandler
in interfaceReadStream<Buffer>
- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the exception handler- Returns:
-
handler
- Specified by:
handler
in interfaceReadStream<Buffer>
- Returns:
-
pause
- Specified by:
pause
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
resume
- Specified by:
resume
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
fetch
- Specified by:
fetch
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
- Specified by:
endHandler
in interfaceReadStream<Buffer>
- Parameters:
endHandler
-- Returns:
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSize
in interfaceWriteStream<Buffer>
- Parameters:
maxSize
- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
- Specified by:
drainHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the handler- Returns:
-
writeHandlerID
- Returns:
- the write handler ID
-
write
Same aswrite(java.lang.String)
but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
str
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofwrite(String)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
str
-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofwrite(String)
that ignores the result of the operation.This method subscribes on the result of
write(String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String)
but you don't need to compose it with other operations.- Parameters:
str
-
-
write
Same aswrite(java.lang.String)
but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
str
-enc
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofwrite(String,String)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
str
-enc
-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofwrite(String,String)
that ignores the result of the operation.This method subscribes on the result of
write(String,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String,String)
but you don't need to compose it with other operations.- Parameters:
str
-enc
-
-
write
LikeWriteStream.write(T)
but with anhandler
called when the message has been written or failed to be written.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
write
in interfaceWriteStream<Buffer>
- Parameters:
message
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
writeAndAwait
in interfaceWriteStream<Buffer>
- Parameters:
message
-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Specified by:
writeAndForget
in interfaceWriteStream<Buffer>
- Parameters:
message
-
-
sendFile
Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename
- file name of the file to send- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename
- file name of the file to send- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String)
that ignores the result of the operation.This method subscribes on the result of
sendFile(String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String)
but you don't need to compose it with other operations.- Parameters:
filename
- file name of the file to send- Returns:
- the instance of NetSocket to chain method calls.
-
sendFile
Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename
- file name of the file to sendoffset
- offset- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String,long)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename
- file name of the file to sendoffset
- offset- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String,long)
that ignores the result of the operation.This method subscribes on the result of
sendFile(String,long)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String,long)
but you don't need to compose it with other operations.- Parameters:
filename
- file name of the file to sendoffset
- offset- Returns:
- the instance of NetSocket to chain method calls.
-
sendFile
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> sendFile(String filename, long offset, long length) Same assendFile(java.lang.String)
but also takes a handler that will be called when the send has completed or a failure has occurredUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename
- file name of the file to sendoffset
- offsetlength
- length- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String,long,long)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename
- file name of the file to sendoffset
- offsetlength
- length- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String,long,long)
that ignores the result of the operation.This method subscribes on the result of
sendFile(String,long,long)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String,long,long)
but you don't need to compose it with other operations.- Parameters:
filename
- file name of the file to sendoffset
- offsetlength
- length- Returns:
- the instance of NetSocket to chain method calls.
-
remoteAddress
- Returns:
- the remote address for this connection, possibly
null
(e.g a server bound on a domain socket). IfuseProxyProtocol
is set totrue
, the address returned will be of the actual connecting client.
-
remoteAddress
- Parameters:
real
-- Returns:
-
localAddress
- Returns:
- the local address for this connection, possibly
null
(e.g a server bound on a domain socket) IfuseProxyProtocol
is set totrue
, the address returned will be of the proxy.
-
localAddress
- Parameters:
real
-- Returns:
-
end
Callsend(io.vertx.mutiny.core.buffer.Buffer)
.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
end
in interfaceWriteStream<Buffer>
- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofWriteStream.end()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwait
in interfaceWriteStream<Buffer>
- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget()Variant ofWriteStream.end()
that ignores the result of the operation.This method subscribes on the result of
WriteStream.end()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromWriteStream.end()
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<Buffer>
-
close
Close the NetSocket and notify thehandler
when the operation completes.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
Blocking variant ofclose()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
closeAndForget
public void closeAndForget() -
closeHandler
- Parameters:
handler
- the handler- Returns:
-
upgradeToSsl
Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
upgradeToSslAndAwait
Blocking variant ofupgradeToSsl()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
upgradeToSslAndForget
Variant ofupgradeToSsl()
that ignores the result of the operation.This method subscribes on the result of
upgradeToSsl()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromupgradeToSsl()
but you don't need to compose it with other operations.- Returns:
- the instance of NetSocket to chain method calls.
-
upgradeToSsl
Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
serverName
- the server name- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
upgradeToSslAndAwait
Blocking variant ofupgradeToSsl(String)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
serverName
- the server name- Returns:
- the Void instance produced by the operation.
-
upgradeToSslAndForget
Variant ofupgradeToSsl(String)
that ignores the result of the operation.This method subscribes on the result of
upgradeToSsl(String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromupgradeToSsl(String)
but you don't need to compose it with other operations.- Parameters:
serverName
- the server name- Returns:
- the instance of NetSocket to chain method calls.
-
isSsl
public boolean isSsl()- Returns:
- true if this
NetSocket
is encrypted via SSL/TLS.
-
indicatedServerName
- Returns:
- the indicated server name
-
applicationLayerProtocol
- Returns:
- the application-level protocol negotiated during the TLS handshake
-
sslSession
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
-
toMulti
- Specified by:
toMulti
in interfaceReadStream<Buffer>
-
toBlockingIterable
-
toBlockingStream
-
newInstance
-