Class NetSocket
- java.lang.Object
-
- io.vertx.mutiny.core.net.NetSocket
-
- All Implemented Interfaces:
ReadStream<Buffer>,StreamBase,WriteStream<Buffer>
public class NetSocket extends Object implements 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
NetClientwhen a connection to a server is made, or on the server side by aNetServerwhen a server accepts a connection.It implements both and so it can be used with
NOTE: This class has been automatically generated from thePumpto pump data with flow control.originalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<NetSocket>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description NetSocket(io.vertx.core.net.NetSocket delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>close()Close the NetSocket and notify thehandlerwhen the operation completes.VoidcloseAndAwait()Blocking variant ofclose().voidcloseAndForget()Variant ofclose()that ignores the result of the operation.NetSocketcloseHandler(Consumer<Void> handler)NetSocketdrainHandler(Consumer<Void> handler)io.smallrye.mutiny.Uni<Void>end()io.smallrye.mutiny.Uni<Void>end(Buffer data)Same as but with anhandlercalled when the operation completesVoidendAndAwait()Blocking variant ofWriteStream.end().VoidendAndAwait(Buffer data)Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer).voidendAndForget()Variant ofWriteStream.end()that ignores the result of the operation.voidendAndForget(Buffer data)Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.NetSocketendHandler(Consumer<Void> endHandler)booleanequals(Object o)NetSocketexceptionHandler(Consumer<Throwable> handler)NetSocketfetch(long amount)io.vertx.core.net.NetSocketgetDelegate()NetSockethandler(Consumer<Buffer> handler)inthashCode()StringindicatedServerName()booleanisSsl()SocketAddresslocalAddress()static NetSocketnewInstance(io.vertx.core.net.NetSocket arg)NetSocketpause()Pipe<Buffer>pipe()io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<Buffer> dst)Pipe thisReadStreamto theWriteStream.VoidpipeToAndAwait(WriteStream<Buffer> dst)Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream.) voidpipeToAndForget(WriteStream<Buffer> dst)Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.) SocketAddressremoteAddress()NetSocketresume()io.smallrye.mutiny.Uni<Void>sendFile(String filename)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>sendFile(String filename, long offset)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>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 occurredVoidsendFileAndAwait(String filename)Blocking variant ofsendFile(String).VoidsendFileAndAwait(String filename, long offset)Blocking variant ofsendFile(String,long).VoidsendFileAndAwait(String filename, long offset, long length)Blocking variant ofsendFile(String,long,long).NetSocketsendFileAndForget(String filename)Variant ofsendFile(String)that ignores the result of the operation.NetSocketsendFileAndForget(String filename, long offset)Variant ofsendFile(String,long)that ignores the result of the operation.NetSocketsendFileAndForget(String filename, long offset, long length)Variant ofsendFile(String,long,long)that ignores the result of the operation.NetSocketsetWriteQueueMaxSize(int maxSize)SSLSessionsslSession()Iterable<Buffer>toBlockingIterable()Stream<Buffer>toBlockingStream()io.smallrye.mutiny.Multi<Buffer>toMulti()StringtoString()WriteStreamSubscriber<Buffer>toSubscriber()NetSocketupgradeToSsl(String serverName, Consumer<Void> handler)NetSocketupgradeToSsl(Consumer<Void> handler)io.smallrye.mutiny.Uni<Void>write(Buffer message)Like but with anhandlercalled when the message has been written or failed to be written.io.smallrye.mutiny.Uni<Void>write(String str)Same aswrite(java.lang.String)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>write(String str, String enc)Same aswrite(java.lang.String)but with anhandlercalled when the operation completesVoidwriteAndAwait(Buffer message)Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer).VoidwriteAndAwait(String str)Blocking variant ofwrite(String).VoidwriteAndAwait(String str, String enc)Blocking variant ofwrite(String,String).NetSocketwriteAndForget(Buffer data)NetSocketwriteAndForget(String str)Variant ofwrite(String)that ignores the result of the operation.NetSocketwriteAndForget(String str, String enc)Variant ofwrite(String,String)that ignores the result of the operation.StringwriteHandlerID()booleanwriteQueueFull()
-
-
-
Method Detail
-
getDelegate
public io.vertx.core.net.NetSocket getDelegate()
- Specified by:
getDelegatein interfaceReadStream<Buffer>- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<Buffer>
-
toSubscriber
public WriteStreamSubscriber<Buffer> toSubscriber()
-
end
public io.smallrye.mutiny.Uni<Void> end(Buffer data)
Same as but with anhandlercalled 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:
endin interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void endAndAwait(Buffer data)
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:
endAndAwaitin interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the Void instance produced by the operation
-
writeQueueFull
public boolean writeQueueFull()
- Specified by:
writeQueueFullin interfaceWriteStream<Buffer>- Returns:
- true if write queue is full
-
pipe
public Pipe<Buffer> pipe()
- Specified by:
pipein interfaceReadStream<Buffer>- Returns:
- a pipe
-
pipeTo
public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Buffer> dst)
Pipe thisReadStreamto 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
handlerwill 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:
pipeToin interfaceReadStream<Buffer>- Parameters:
dst- the destination write stream- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
public Void pipeToAndAwait(WriteStream<Buffer> dst)
Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#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:
pipeToAndAwaitin interfaceReadStream<Buffer>- Parameters:
dst- the destination write stream- Returns:
- the Void instance produced by the operation
-
exceptionHandler
public NetSocket exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceReadStream<Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
public NetSocket handler(Consumer<Buffer> handler)
- Specified by:
handlerin interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
pause
public NetSocket pause()
- Specified by:
pausein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
public NetSocket resume()
- Specified by:
resumein interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public NetSocket fetch(long amount)
- Specified by:
fetchin interfaceReadStream<Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public NetSocket endHandler(Consumer<Void> endHandler)
- Specified by:
endHandlerin interfaceReadStream<Buffer>- Parameters:
endHandler-- Returns:
-
setWriteQueueMaxSize
public NetSocket setWriteQueueMaxSize(int maxSize)
- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<Buffer>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
public NetSocket drainHandler(Consumer<Void> handler)
- Specified by:
drainHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
writeHandlerID
public String writeHandlerID()
- Returns:
- the write handler ID
-
write
public io.smallrye.mutiny.Uni<Void> write(String str)
Same aswrite(java.lang.String)but with anhandlercalled 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(String str)
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
-
write
public io.smallrye.mutiny.Uni<Void> write(String str, String enc)
Same aswrite(java.lang.String)but with anhandlercalled 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(String str, String enc)
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
-
write
public io.smallrye.mutiny.Uni<Void> write(Buffer message)
Like but with anhandlercalled 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:
writein interfaceWriteStream<Buffer>- Parameters:
message-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(Buffer message)
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:
writeAndAwaitin interfaceWriteStream<Buffer>- Parameters:
message-- Returns:
- the Void instance produced by the operation
-
sendFile
public io.smallrye.mutiny.Uni<Void> sendFile(String filename)
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:
- a reference to this, so the API can be used fluently
-
sendFileAndAwait
public Void sendFileAndAwait(String filename)
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:
- a reference to this, so the API can be used fluently
-
sendFile
public io.smallrye.mutiny.Uni<Void> sendFile(String filename, long offset)
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:
- a reference to this, so the API can be used fluently
-
sendFileAndAwait
public Void sendFileAndAwait(String filename, long offset)
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:
- a reference to this, so the API can be used fluently
-
sendFile
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:
- a reference to this, so the API can be used fluently
-
sendFileAndAwait
public Void sendFileAndAwait(String filename, long offset, long length)
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:
- a reference to this, so the API can be used fluently
-
remoteAddress
public SocketAddress remoteAddress()
- Returns:
- the remote address for this connection, possibly
null(e.g a server bound on a domain socket)
-
localAddress
public SocketAddress localAddress()
- Returns:
- the local address for this connection, possibly
null(e.g a server bound on a domain socket)
-
end
public io.smallrye.mutiny.Uni<Void> 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:
endin interfaceWriteStream<Buffer>- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void 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:
endAndAwaitin interfaceWriteStream<Buffer>- Returns:
- the Void instance produced by the operation
-
close
public io.smallrye.mutiny.Uni<Void> close()
Close the NetSocket and notify thehandlerwhen 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
public Void 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
-
closeHandler
public NetSocket closeHandler(Consumer<Void> handler)
- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
upgradeToSsl
public NetSocket upgradeToSsl(Consumer<Void> handler)
- Parameters:
handler- the handler will be notified when it's upgraded- Returns:
- a reference to this, so the API can be used fluently
-
upgradeToSsl
public NetSocket upgradeToSsl(String serverName, Consumer<Void> handler)
- Parameters:
serverName- the server namehandler- the handler will be notified when it's upgraded- Returns:
- a reference to this, so the API can be used fluently
-
isSsl
public boolean isSsl()
- Returns:
- true if this
NetSocketis encrypted via SSL/TLS.
-
indicatedServerName
public String indicatedServerName()
- Returns:
- the indicated server name
-
sslSession
public SSLSession sslSession()
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
-
endAndForget
public 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.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.- Parameters:
data- the data to write
-
pipeToAndForget
public void pipeToAndForget(WriteStream<Buffer> dst)
Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreambut you don't need to compose it with other operations.) - Parameters:
dst-
-
writeAndForget
public NetSocket writeAndForget(String str)
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- the string to write- Returns:
- a reference to this, so the API can be used fluently
-
writeAndForget
public NetSocket writeAndForget(String str, String enc)
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- the string to writeenc- the encoding to use- Returns:
- a reference to this, so the API can be used fluently
-
sendFileAndForget
public NetSocket sendFileAndForget(String filename)
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:
- a reference to this, so the API can be used fluently
-
sendFileAndForget
public NetSocket sendFileAndForget(String filename, long offset)
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:
- a reference to this, so the API can be used fluently
-
sendFileAndForget
public NetSocket sendFileAndForget(String filename, long offset, long length)
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:
- a reference to this, so the API can be used fluently
-
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.
-
closeAndForget
public void closeAndForget()
-
toMulti
public io.smallrye.mutiny.Multi<Buffer> toMulti()
- Specified by:
toMultiin interfaceReadStream<Buffer>
-
newInstance
public static NetSocket newInstance(io.vertx.core.net.NetSocket arg)
-
-