Top Fields Constructors Methods
io.vertx.core.http.impl

pack-priv Class HttpNetSocket

extends Object
implements NetSocket
Class Inheritance
All Implemented Interfaces
io.vertx.core.net.NetSocket, io.vertx.core.streams.WriteStream, io.vertx.core.streams.StreamBase, io.vertx.core.streams.ReadStream
Imports
io.vertx.codegen.annotations.Nullable, io.vertx.core.*, io.vertx.core.buffer.Buffer, io.vertx.core.file.AsyncFile, io.vertx.core.http.HttpClosedException, .StreamResetException, io.vertx.core.impl.ContextInternal, .VertxInternal, io.vertx.core.net.NetSocket, .SocketAddress, io.vertx.core.net.impl.ConnectionBase, io.vertx.core.streams.ReadStream, .WriteStream, javax.net.ssl.SSLPeerUnverifiedException, .SSLSession, javax.security.cert.X509Certificate, java.nio.channels.ClosedChannelException, java.security.cert.Certificate, java.util.List

Author
Julien Viet

Field Summary

Modifier and TypeField and Description
private Handler<Void>
private final ConnectionBase
private final ContextInternal
private Handler<Buffer>
private Handler<Void>
private Handler<Throwable>
private final ReadStream<Buffer>
private final WriteStream<Buffer>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
public Future<Void>
close()

Implements io.vertx.core.net.NetSocket.close.

Close the NetSocket

public void
close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.close.

Close the NetSocket and notify the handler when the operation completes.

public NetSocket
pack-priv Handler<Void>
public NetSocket
public Future<Void>
end(Buffer
the data to write
data
)

Overrides default io.vertx.core.streams.WriteStream.end.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Same as end() but writes some data to the stream before ending.

public void
end(Buffer buffer, Handler<AsyncResult<Void>> handler)

Overrides default io.vertx.core.streams.WriteStream.end.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Same as end(T) but with an handler called when the operation completes

public Future<Void>
public void
public synchronized NetSocket
endHandler(Handler<Void> handler)

Implements io.vertx.core.net.NetSocket.endHandler.

This handler might be called after the close handler when the socket is paused and there are still buffers to deliver.

pack-priv synchronized Handler<Void>
public synchronized NetSocket
pack-priv synchronized Handler<Throwable>
public NetSocket
fetch(long amount)

Implements io.vertx.core.net.NetSocket.fetch.

Fetch the specified amount of elements.

private void
handleData(Buffer buf)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

private void
private void
public synchronized NetSocket
pack-priv synchronized Handler<Buffer>
public String
indicatedServerName()

Implements io.vertx.core.net.NetSocket.indicatedServerName.

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

public boolean
public SocketAddress
public SocketAddress
localAddress(boolean real)

Implements io.vertx.core.net.NetSocket.localAddress.

Like localAddress() ()} but returns the server local address when real is true

pack-priv static HttpNetSocket
netSocket(ConnectionBase conn, ContextInternal context, ReadStream<Buffer> readStream, WriteStream<Buffer> writeStream)

public NetSocket
pause()

Implements io.vertx.core.net.NetSocket.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public X509Certificate[]
peerCertificateChain()

Implements io.vertx.core.net.NetSocket.peerCertificateChain.

References Deprecated X509Certificate is deprecated or references (maybe indirectly) at least one deprecated element.

public List<Certificate>
public SocketAddress
public SocketAddress
remoteAddress(boolean real)

Implements io.vertx.core.net.NetSocket.remoteAddress.

Like remoteAddress() but returns the proxy remote address when real is true

public NetSocket
resume()

Implements io.vertx.core.net.NetSocket.resume.

Resume reading, and sets the buffer in flowing mode.

public Future<Void>
sendFile(String
file name of the file to send
filename
,
long
offset
offset
,
long
length
length
)

Implements io.vertx.core.net.NetSocket.sendFile.

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.

public NetSocket
sendFile(String
file name of the file to send
filename
,
long
offset
offset
,
long
length
length
,
Handler<AsyncResult<Void>>
handler
resultHandler
)

Implements io.vertx.core.net.NetSocket.sendFile.

Same as sendFile(String, long, long) but also takes a handler that will be called when the send has completed or a failure has occurred

public NetSocket
setWriteQueueMaxSize(int
the max size of the write stream
maxSize
)

Implements io.vertx.core.net.NetSocket.setWriteQueueMaxSize.

Set the maximum size of the write queue to maxSize.

public SSLSession
public NetSocket
upgradeToSsl(Handler<AsyncResult<Void>>
the handler will be notified when it's upgraded
handler
)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Upgrade channel to use SSL/TLS.

public NetSocket
upgradeToSsl(String
the server name
serverName
,
Handler<AsyncResult<Void>>
the handler will be notified when it's upgraded
handler
)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Upgrade channel to use SSL/TLS.

public Future<Void>
upgradeToSsl()

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Like upgradeToSsl(Handler) but returns a Future of the asynchronous result

public Future<Void>
upgradeToSsl(String serverName)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Like upgradeToSsl(String, Handler) but returns a Future of the asynchronous result

public Future<Void>
write(Buffer
the data to write
data
)

Implements io.vertx.core.streams.WriteStream.write.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Write some data to the stream.

public void
write(Buffer data, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Like write(Object) but with an handler called when the message has been written or failed to be written.

public Future<Void>
write(String
the string to write
str
,
String
the encoding to use
enc
)

Implements io.vertx.core.net.NetSocket.write.

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

public void
write(String str, String enc, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

Same as write(String, String) but with an handler called when the operation completes

public Future<Void>
write(String
the string to write
str
)

Implements io.vertx.core.net.NetSocket.write.

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

public void
write(String str, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

Same as write(String) but with an handler called when the operation completes

public String
writeHandlerID()

Implements io.vertx.core.net.NetSocket.writeHandlerID.

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

public boolean
writeQueueFull()

Implements io.vertx.core.streams.WriteStream.writeQueueFull.

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeHandlerback to summary
private Handler<Void> closeHandler
connback to summary
private final ConnectionBase conn
contextback to summary
private final ContextInternal context
dataHandlerback to summary
private Handler<Buffer> dataHandler
endHandlerback to summary
private Handler<Void> endHandler
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
readStreamback to summary
private final ReadStream<Buffer> readStream
writeStreamback to summary
private final WriteStream<Buffer> writeStream

Constructor Detail

HttpNetSocketback to summary
private HttpNetSocket(ConnectionBase conn, ContextInternal context, ReadStream<Buffer> readStream, WriteStream<Buffer> writeStream)

Method Detail

applicationLayerProtocolback to summary
public String applicationLayerProtocol()

Implements io.vertx.core.net.NetSocket.applicationLayerProtocol.

Returns:String

Doc from io.vertx.core.net.NetSocket.applicationLayerProtocol.

the application-level protocol negotiated during the TLS handshake

Annotations
@Override
closeback to summary
public Future<Void> close()

Implements io.vertx.core.net.NetSocket.close.

Doc from io.vertx.core.net.NetSocket.close.

Close the NetSocket

Returns:Future<Void>

a future completed with the result

Annotations
@Override
closeback to summary
public void close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.close.

Doc from io.vertx.core.net.NetSocket.close.

Close the NetSocket and notify the handler when the operation completes.

Annotations
@Override
closeHandlerback to summary
public NetSocket closeHandler(@Nullable Handler<Void> handler)
Annotations
@Override
closeHandlerback to summary
pack-priv Handler<Void> closeHandler()
drainHandlerback to summary
public NetSocket drainHandler(Handler<Void> handler)

Implements io.vertx.core.net.NetSocket.drainHandler.

Annotations
@Override
endback to summary
public Future<Void> end(Buffer data)

Overrides default io.vertx.core.streams.WriteStream.end.

Doc from io.vertx.core.streams.WriteStream.end.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Same as end() but writes some data to the stream before ending.

Parameters
data:Buffer

the data to write

Returns:Future<Void>

a future completed with the result

Annotations
@Override
endback to summary
public void end(Buffer buffer, Handler<AsyncResult<Void>> handler)

Overrides default io.vertx.core.streams.WriteStream.end.

Doc from io.vertx.core.streams.WriteStream.end.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Same as end(T) but with an handler called when the operation completes

Annotations
@Override
endback to summary
public Future<Void> end()

Implements io.vertx.core.net.NetSocket.end.

Doc from io.vertx.core.net.NetSocket.end.

Calls close()

Returns:Future<Void>

a future completed with the result

Annotations
@Override
endback to summary
public void end(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.end.

Doc from io.vertx.core.net.NetSocket.end.

Calls end().

Annotations
@Override
endHandlerback to summary
public synchronized NetSocket endHandler(Handler<Void> handler)

Implements io.vertx.core.net.NetSocket.endHandler.

Doc from io.vertx.core.net.NetSocket.endHandler.

This handler might be called after the close handler when the socket is paused and there are still buffers to deliver.

Annotations
@Override
endHandlerback to summary
pack-priv synchronized Handler<Void> endHandler()
exceptionHandlerback to summary
public synchronized NetSocket exceptionHandler(Handler<Throwable> handler)

Implements io.vertx.core.net.NetSocket.exceptionHandler.

Annotations
@Override
exceptionHandlerback to summary
pack-priv synchronized Handler<Throwable> exceptionHandler()
fetchback to summary
public NetSocket fetch(long amount)

Implements io.vertx.core.net.NetSocket.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:NetSocket

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

Annotations
@Override
handleDataback to summary
private void handleData(Buffer buf)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

handleEndback to summary
private void handleEnd(Void v)
handleExceptionback to summary
private void handleException(Throwable cause)
handlerback to summary
public synchronized NetSocket handler(Handler<Buffer> handler)

Implements io.vertx.core.net.NetSocket.handler.

Annotations
@Override
handlerback to summary
pack-priv synchronized Handler<Buffer> handler()
indicatedServerNameback to summary
public String indicatedServerName()

Implements io.vertx.core.net.NetSocket.indicatedServerName.

Doc from io.vertx.core.net.NetSocket.indicatedServerName.

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

Returns:String

the indicated server name

Annotations
@Override
isSslback to summary
public boolean isSsl()

Implements io.vertx.core.net.NetSocket.isSsl.

Returns:boolean

Doc from io.vertx.core.net.NetSocket.isSsl.

true if this io.vertx.core.net.NetSocket is encrypted via SSL/TLS.

Annotations
@Override
localAddressback to summary
public SocketAddress localAddress()

Implements io.vertx.core.net.NetSocket.localAddress.

Returns:SocketAddress

Doc from io.vertx.core.net.NetSocket.localAddress.

the local address for this connection, possibly null (e.g a server bound on a domain socket) If useProxyProtocol is set to true, the address returned will be of the proxy.

Annotations
@Override
localAddressback to summary
public SocketAddress localAddress(boolean real)

Implements io.vertx.core.net.NetSocket.localAddress.

Doc from io.vertx.core.net.NetSocket.localAddress.

Like localAddress() ()} but returns the server local address when real is true

Annotations
@Override
netSocketback to summary
pack-priv static HttpNetSocket netSocket(ConnectionBase conn, ContextInternal context, ReadStream<Buffer> readStream, WriteStream<Buffer> writeStream)
pauseback to summary
public NetSocket pause()

Implements io.vertx.core.net.NetSocket.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:NetSocket

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

Annotations
@Override
peerCertificateChainback to summary
public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException

Implements io.vertx.core.net.NetSocket.peerCertificateChain.

References Deprecated

X509Certificate is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns:X509Certificate[]

Doc from io.vertx.core.net.NetSocket.peerCertificateChain.

an ordered array of the peer certificates. Returns null if connection is not SSL.

Annotations
@Override
Exceptions
SSLPeerUnverifiedException:

Doc from io.vertx.core.net.NetSocket.peerCertificateChain.

SSL peer's identity has not been verified.

peerCertificatesback to summary
public List<Certificate> peerCertificates() throws SSLPeerUnverifiedException

Implements io.vertx.core.net.NetSocket.peerCertificates.

Returns:List<Certificate>

Doc from io.vertx.core.net.NetSocket.peerCertificates.

an ordered list of the peer certificates. Returns null if connection is not SSL.

Annotations
@Override
Exceptions
SSLPeerUnverifiedException:

Doc from io.vertx.core.net.NetSocket.peerCertificates.

SSL peer's identity has not been verified.

remoteAddressback to summary
public SocketAddress remoteAddress()

Implements io.vertx.core.net.NetSocket.remoteAddress.

Returns:SocketAddress

Doc from io.vertx.core.net.NetSocket.remoteAddress.

the remote address for this connection, possibly null (e.g a server bound on a domain socket). If useProxyProtocol is set to true, the address returned will be of the actual connecting client.

Annotations
@Override
remoteAddressback to summary
public SocketAddress remoteAddress(boolean real)

Implements io.vertx.core.net.NetSocket.remoteAddress.

Doc from io.vertx.core.net.NetSocket.remoteAddress.

Like remoteAddress() but returns the proxy remote address when real is true

Annotations
@Override
resumeback to summary
public NetSocket resume()

Implements io.vertx.core.net.NetSocket.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:NetSocket

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

Annotations
@Override
sendFileback to summary
public Future<Void> sendFile(String filename, long offset, long length)

Implements io.vertx.core.net.NetSocket.sendFile.

Doc from io.vertx.core.net.NetSocket.sendFile.

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.

Parameters
filename:String

file name of the file to send

offset:long

offset

length:long

length

Returns:Future<Void>

a future result of the send operation

Annotations
@Override
sendFileback to summary
public NetSocket sendFile(String filename, long offset, long length, Handler<AsyncResult<Void>> resultHandler)

Implements io.vertx.core.net.NetSocket.sendFile.

Doc from io.vertx.core.net.NetSocket.sendFile.

Same as sendFile(String, long, long) but also takes a handler that will be called when the send has completed or a failure has occurred

Parameters
filename:String

file name of the file to send

offset:long

offset

length:long

length

resultHandler:Handler<AsyncResult<Void>>

handler

Returns:NetSocket

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

Annotations
@Override
setWriteQueueMaxSizeback to summary
public NetSocket setWriteQueueMaxSize(int maxSize)

Implements io.vertx.core.net.NetSocket.setWriteQueueMaxSize.

Doc from io.vertx.core.streams.WriteStream.setWriteQueueMaxSize.

Set the maximum size of the write queue to maxSize. You will still be able to write to the stream even if there is more than maxSize items in the write queue. This is used as an indicator by classes such as Pipe to provide flow control.

The value is defined by the implementation of the stream, e.g in bytes for a io.vertx.core.net.NetSocket, etc...

Parameters
maxSize:int

the max size of the write stream

Returns:NetSocket

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

Annotations
@Override
sslSessionback to summary
public SSLSession sslSession()

Implements io.vertx.core.net.NetSocket.sslSession.

Returns:SSLSession

Doc from io.vertx.core.net.NetSocket.sslSession.

SSLSession associated with the underlying socket. Returns null if connection is not SSL.

Annotations
@Override
upgradeToSslback to summary
public NetSocket upgradeToSsl(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Doc from io.vertx.core.net.NetSocket.upgradeToSsl.

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

Parameters
handler:Handler<AsyncResult<Void>>

the handler will be notified when it's upgraded

Returns:NetSocket

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

Annotations
@Override
upgradeToSslback to summary
public NetSocket upgradeToSsl(String serverName, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Doc from io.vertx.core.net.NetSocket.upgradeToSsl.

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

Parameters
serverName:String

the server name

handler:Handler<AsyncResult<Void>>

the handler will be notified when it's upgraded

Returns:NetSocket

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

Annotations
@Override
upgradeToSslback to summary
public Future<Void> upgradeToSsl()

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Doc from io.vertx.core.net.NetSocket.upgradeToSsl.

Like upgradeToSsl(Handler) but returns a Future of the asynchronous result

Annotations
@Override
upgradeToSslback to summary
public Future<Void> upgradeToSsl(String serverName)

Implements io.vertx.core.net.NetSocket.upgradeToSsl.

Doc from io.vertx.core.net.NetSocket.upgradeToSsl.

Like upgradeToSsl(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
writeback to summary
public Future<Void> write(Buffer data)

Implements io.vertx.core.streams.WriteStream.write.

Doc from io.vertx.core.streams.WriteStream.write.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Write some data to the stream.

The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull method before writing. This is done automatically if using a Pipe.

When the data is moved from the queue to the actual medium, the returned Future will be completed with the write result, e.g the future is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.

Parameters
data:Buffer

the data to write

Returns:Future<Void>

a future completed with the write result

Annotations
@Override
writeback to summary
public void write(Buffer data, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

Doc from io.vertx.core.net.NetSocket.write.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Like write(Object) but with an handler called when the message has been written or failed to be written.

Annotations
@Override
writeback to summary
public Future<Void> write(String str, String enc)

Implements io.vertx.core.net.NetSocket.write.

Doc from io.vertx.core.net.NetSocket.write.

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

Parameters
str:String

the string to write

enc:String

the encoding to use

Returns:Future<Void>

a future completed with the result

Annotations
@Override
writeback to summary
public void write(String str, String enc, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

Doc from io.vertx.core.net.NetSocket.write.

Same as write(String, String) but with an handler called when the operation completes

Annotations
@Override
writeback to summary
public Future<Void> write(String str)

Implements io.vertx.core.net.NetSocket.write.

Doc from io.vertx.core.net.NetSocket.write.

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

Parameters
str:String

the string to write

Returns:Future<Void>

a future result of the write

Annotations
@Override
writeback to summary
public void write(String str, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.net.NetSocket.write.

Doc from io.vertx.core.net.NetSocket.write.

Same as write(String) but with an handler called when the operation completes

Annotations
@Override
writeHandlerIDback to summary
public String writeHandlerID()

Implements io.vertx.core.net.NetSocket.writeHandlerID.

Doc from io.vertx.core.net.NetSocket.writeHandlerID.

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

By default, no handler is registered, the feature must be enabled via NetClientOptions#setRegisterWriteHandler(boolean) or NetServerOptions#setRegisterWriteHandler(boolean).

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.

Returns:String

the write handler ID

Annotations
@Override
writeQueueFullback to summary
public boolean writeQueueFull()

Implements io.vertx.core.streams.WriteStream.writeQueueFull.

Doc from io.vertx.core.streams.WriteStream.writeQueueFull.

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Returns:boolean

true if write queue is full

Annotations
@Override