public class DefaultNetSocket extends ConnectionBase implements NetSocket
channel, closeHandler, context, exceptionHandler, vertx| Constructor and Description |
|---|
DefaultNetSocket(VertxInternal vertx,
io.netty.channel.Channel channel,
DefaultContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection
|
NetSocket |
closeHandler(Handler<java.lang.Void> handler)
Set a handler that will be called when the NetSocket is closed
|
NetSocket |
dataHandler(Handler<Buffer> dataHandler)
Set a data handler.
|
NetSocket |
drainHandler(Handler<java.lang.Void> drainHandler)
Set a drain handler on the stream.
|
NetSocket |
endHandler(Handler<java.lang.Void> endHandler)
Set an end handler.
|
NetSocket |
exceptionHandler(Handler<java.lang.Throwable> handler)
Set an exception handler.
|
protected DefaultContext |
getContext() |
protected void |
handleClosed() |
void |
handleInterestedOpsChanged() |
java.net.InetSocketAddress |
localAddress()
Return the local address for this socket
|
NetSocket |
pause()
Pause the
ReadStream. |
java.net.InetSocketAddress |
remoteAddress()
Return the remote address for this socket
|
NetSocket |
resume()
Resume reading.
|
NetSocket |
sendFile(java.lang.String filename)
Tell the kernel 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. |
NetSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
NetSocket |
write(Buffer data)
Write a
Buffer to the request body. |
NetSocket |
write(java.lang.String str)
Write a
String to the connection, encoded in UTF-8. |
NetSocket |
write(java.lang.String str,
java.lang.String enc)
Write a
String to the connection, encoded using the encoding enc. |
java.lang.String |
writeHandlerID()
When a
NetSocket is created it automatically registers an event handler with the event bus, the ID of that
handler is given by writeHandlerID. |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
addFuture, doPause, doResume, doSetWriteQueueMaxSize, doWriteQueueFull, endReadAndFlush, getPeerCertificateChain, handleException, handleHandlerException, isSSL, queueForWrite, sendFile, setContext, setWritable, startRead, writepublic DefaultNetSocket(VertxInternal vertx, io.netty.channel.Channel channel, DefaultContext context)
public java.lang.String writeHandlerID()
NetSocketNetSocket 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.
writeHandlerID in interface NetSocketpublic NetSocket write(Buffer data)
NetSocketBuffer to the request body.write in interface NetSocketwrite in interface WriteStream<NetSocket>public NetSocket write(java.lang.String str)
NetSocketString to the connection, encoded in UTF-8.public NetSocket write(java.lang.String str, java.lang.String enc)
NetSocketString to the connection, encoded using the encoding enc.public NetSocket dataHandler(Handler<Buffer> dataHandler)
ReadStreamdataHandler in interface ReadStream<NetSocket>public NetSocket pause()
ReadStreamReadStream. While the stream is paused, no data will be sent to the dataHandlerpause in interface ReadStream<NetSocket>public NetSocket resume()
ReadStreamReadStream has been paused, reading will recommence on it.resume in interface ReadStream<NetSocket>public NetSocket setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize bytes in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.setWriteQueueMaxSize in interface WriteStream<NetSocket>public boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<NetSocket>public NetSocket endHandler(Handler<java.lang.Void> endHandler)
ReadStreamendHandler in interface ReadStream<NetSocket>public NetSocket drainHandler(Handler<java.lang.Void> drainHandler)
WriteStreamPump for an example of this being used.drainHandler in interface WriteStream<NetSocket>public NetSocket sendFile(java.lang.String filename)
NetSocketfilename 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.public java.net.InetSocketAddress remoteAddress()
NetSocketremoteAddress in interface NetSocketremoteAddress in class ConnectionBasepublic java.net.InetSocketAddress localAddress()
NetSocketlocalAddress in interface NetSocketlocalAddress in class ConnectionBasepublic NetSocket exceptionHandler(Handler<java.lang.Throwable> handler)
ExceptionSupportexceptionHandler in interface ExceptionSupport<NetSocket>public NetSocket closeHandler(Handler<java.lang.Void> handler)
NetSocketcloseHandler in interface NetSocketpublic void close()
ConnectionBaseclose in interface NetSocketclose in class ConnectionBaseprotected DefaultContext getContext()
getContext in class ConnectionBaseprotected void handleClosed()
handleClosed in class ConnectionBasepublic void handleInterestedOpsChanged()
handleInterestedOpsChanged in class ConnectionBase