public class DefaultNetServer extends java.lang.Object implements NetServer, Closeable
| Constructor and Description |
|---|
DefaultNetServer(VertxInternal vertx) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<java.lang.Void>> done)
Close the server.
|
NetServer |
connectHandler(Handler<NetSocket> connectHandler)
Supply a connect handler for this server.
|
int |
getAcceptBacklog() |
java.lang.String |
getKeyStorePassword() |
java.lang.String |
getKeyStorePath() |
int |
getReceiveBufferSize() |
int |
getSendBufferSize() |
int |
getSoLinger() |
int |
getTrafficClass() |
java.lang.String |
getTrustStorePassword() |
java.lang.String |
getTrustStorePath() |
java.lang.String |
host()
The host
|
boolean |
isClientAuthRequired()
Is client auth required?
|
boolean |
isReuseAddress() |
boolean |
isSSL() |
boolean |
isTCPKeepAlive() |
boolean |
isTCPNoDelay() |
boolean |
isUsePooledBuffers() |
NetServer |
listen(int port)
Tell the server to start listening on all available interfaces and port
port. |
NetServer |
listen(int port,
Handler<AsyncResult<NetServer>> listenHandler)
Instruct the server to listen for incoming connections on the specified
port and all available interfaces. |
NetServer |
listen(int port,
java.lang.String host)
Tell the server to start listening on port
port and hostname or ip address given by host. |
NetServer |
listen(int port,
java.lang.String host,
Handler<AsyncResult<NetServer>> listenHandler)
Instruct the server to listen for incoming connections on the specified
port and host. |
int |
port()
The actual port the server is listening on.
|
NetServer |
setAcceptBacklog(int backlog)
Set the accept backlog
|
NetServer |
setClientAuthRequired(boolean required)
Set
required to true if you want the server to request client authentication from any connecting clients. |
NetServer |
setKeyStorePassword(java.lang.String pwd)
Set the password for the SSL key store.
|
NetServer |
setKeyStorePath(java.lang.String path)
Set the path to the SSL key store.
|
NetServer |
setReceiveBufferSize(int size)
Set the TCP receive buffer size for connections created by this instance to
size in bytes. |
NetServer |
setReuseAddress(boolean reuse)
Set the TCP reuseAddress setting for connections created by this instance to
reuse. |
NetServer |
setSendBufferSize(int size)
Set the TCP send buffer size for connections created by this instance to
size in bytes. |
NetServer |
setSoLinger(int linger)
Set the TCP soLinger setting for connections created by this instance to
linger. |
NetServer |
setSSL(boolean ssl)
If
ssl is true, this signifies that any connections will be SSL connections. |
NetServer |
setTCPKeepAlive(boolean keepAlive)
Set the TCP keepAlive setting for connections created by this instance to
keepAlive. |
NetServer |
setTCPNoDelay(boolean tcpNoDelay)
If
tcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance. |
NetServer |
setTrafficClass(int trafficClass)
Set the TCP trafficClass setting for connections created by this instance to
trafficClass. |
NetServer |
setTrustStorePassword(java.lang.String pwd)
Set the password for the SSL trust store.
|
NetServer |
setTrustStorePath(java.lang.String path)
Set the path to the SSL trust store.
|
NetServer |
setUsePooledBuffers(boolean pooledBuffers)
Set if vertx should use pooled buffers for performance reasons.
|
public DefaultNetServer(VertxInternal vertx)
public NetServer connectHandler(Handler<NetSocket> connectHandler)
NetServerNetSocket and passes it to the
connect handler.connectHandler in interface NetServerpublic NetServer listen(int port)
NetServerport. Be aware this is an
async operation and the server may not bound on return of the method.public NetServer listen(int port, Handler<AsyncResult<NetServer>> listenHandler)
NetServerport and all available interfaces.public NetServer listen(int port, java.lang.String host)
NetServerport and hostname or ip address given by host. Be aware this is an
async operation and the server may not bound on return of the method.public NetServer listen(int port, java.lang.String host, Handler<AsyncResult<NetServer>> listenHandler)
NetServerport and host. host can
be a host name or an IP address.public void close()
NetServerpublic void close(Handler<AsyncResult<java.lang.Void>> done)
NetServerdone will be called
when the close is complete.public java.lang.String host()
NetServerpublic int port()
NetServerpublic boolean isTCPNoDelay()
isTCPNoDelay in interface TCPSupport<NetServer>public int getSendBufferSize()
getSendBufferSize in interface TCPSupport<NetServer>public int getReceiveBufferSize()
getReceiveBufferSize in interface TCPSupport<NetServer>public boolean isTCPKeepAlive()
isTCPKeepAlive in interface TCPSupport<NetServer>public boolean isReuseAddress()
isReuseAddress in interface TCPSupport<NetServer>public int getSoLinger()
getSoLinger in interface TCPSupport<NetServer>public int getTrafficClass()
getTrafficClass in interface TCPSupport<NetServer>public int getAcceptBacklog()
getAcceptBacklog in interface ServerTCPSupport<NetServer>public NetServer setTCPNoDelay(boolean tcpNoDelay)
TCPSupporttcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance.setTCPNoDelay in interface TCPSupport<NetServer>public NetServer setSendBufferSize(int size)
TCPSupportsize in bytes.setSendBufferSize in interface TCPSupport<NetServer>public NetServer setReceiveBufferSize(int size)
TCPSupportsize in bytes.setReceiveBufferSize in interface TCPSupport<NetServer>public NetServer setTCPKeepAlive(boolean keepAlive)
TCPSupportkeepAlive.setTCPKeepAlive in interface TCPSupport<NetServer>public NetServer setReuseAddress(boolean reuse)
TCPSupportreuse.setReuseAddress in interface TCPSupport<NetServer>public NetServer setSoLinger(int linger)
TCPSupportlinger.
Using a negative value will disable soLinger.setSoLinger in interface TCPSupport<NetServer>public NetServer setTrafficClass(int trafficClass)
TCPSupporttrafficClass.setTrafficClass in interface TCPSupport<NetServer>public NetServer setAcceptBacklog(int backlog)
ServerTCPSupportsetAcceptBacklog in interface ServerTCPSupport<NetServer>public boolean isSSL()
isSSL in interface SSLSupport<NetServer>public java.lang.String getKeyStorePath()
getKeyStorePath in interface SSLSupport<NetServer>public java.lang.String getKeyStorePassword()
getKeyStorePassword in interface SSLSupport<NetServer>public java.lang.String getTrustStorePath()
getTrustStorePath in interface SSLSupport<NetServer>public java.lang.String getTrustStorePassword()
getTrustStorePassword in interface SSLSupport<NetServer>public boolean isClientAuthRequired()
ServerSSLSupportisClientAuthRequired in interface ServerSSLSupport<NetServer>public NetServer setSSL(boolean ssl)
SSLSupportssl is true, this signifies that any connections will be SSL connections.setSSL in interface SSLSupport<NetServer>public NetServer setKeyStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The SSL key store is a standard Java Key Store, and will contain the client certificate. Client certificates are only required if the server requests client authentication.
setKeyStorePath in interface SSLSupport<NetServer>public NetServer setKeyStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setKeyStorePassword in interface SSLSupport<NetServer>public NetServer setTrustStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The trust store is a standard Java Key Store, and should contain the certificates of any servers that the client trusts.
setTrustStorePath in interface SSLSupport<NetServer>public NetServer setTrustStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setTrustStorePassword in interface SSLSupport<NetServer>public NetServer setClientAuthRequired(boolean required)
ServerSSLSupportrequired to true if you want the server to request client authentication from any connecting clients. This
is an extra level of security in SSL, and requires clients to provide client certificates. Those certificates must be added
to the server trust store.setClientAuthRequired in interface ServerSSLSupport<NetServer>public NetServer setUsePooledBuffers(boolean pooledBuffers)
TCPSupportsetUsePooledBuffers in interface TCPSupport<NetServer>public boolean isUsePooledBuffers()
isUsePooledBuffers in interface TCPSupport<NetServer>true if pooled buffers are used