Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.vertx.groovy.core.net
[Groovy] Class NetClient

    java.lang.Object
      org.vertx.groovy.core.net.NetClient

    abstract class NetClient

A TCP/SSL client.

Multiple connections to different servers can be made using the same instance.

This client supports a configurable number of connection attempts and a configurable delay between attempts.

If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread then an event loop will be assigned to the instance and used when any of its handlers are called.

Instances cannot be used from worker verticles

Authors:
  Peter Ledbrook
  Tim Fox

Field Summary
`protected NetClient` | `jClient`

Method Summary
`void` | `close()` Close the client.
`NetClient` | `connect(int port, java.lang.Object hndlr)` Attempt to open a connection to a server at the specific `port` and host `localhost` The connect is done asynchronously and on success, a NetSocket instance is supplied via the `connectHandler` instance
`NetClient` | `connect(int port, java.lang.String host, groovy.lang.Closure hndlr)` Attempt to open a connection to a server at the specific `port` and `host`.
`java.lang.Integer` | `getBossThreads()` @return The number of boss threads
`java.lang.Long` | `getConnectTimeout()` @return The connect timeout
`java.lang.String` | `getKeyStorePassword()` @return The keystore password
`java.lang.String` | `getKeyStorePath()` @return The path to the key store
`java.lang.Integer` | `getReceiveBufferSize()` @return The TCP receive buffer size
`int` | `getReconnectAttempts()` Get the number of reconnect attempts
`long` | `getReconnectInterval()` Get the reconnect interval, in milliseconds.
`java.lang.Integer` | `getSendBufferSize()` @return The TCP send buffer size
`java.lang.Integer` | `getTrafficClass()` @return the value of TCP traffic class
`java.lang.String` | `getTrustStorePassword()` @return The trust store password
`java.lang.String` | `getTrustStorePath()` @return The trust store path
`java.lang.Boolean` | `isReuseAddress()` @return The value of TCP reuse address
`boolean` | `isSSL()` @return true if this client will make SSL connections
`java.lang.Boolean` | `isSoLinger()` @return the value of TCP so linger
`java.lang.Boolean` | `isTCPKeepAlive()` @return true if TCP keep alive is enabled
`java.lang.Boolean` | `isTCPNoDelay()` @return true if Nagle's algorithm is disabled.
`NetClient` | `setBossThreads(long threads)` Set the number of boss threads to use.
`NetClient` | `setConnectTimeout(long timeout)` Set the connect timeout in milliseconds
`NetClient` | `setKeyStorePassword(java.lang.String pwd)` Set the password for the SSL key store.
`NetClient` | `setKeyStorePath(java.lang.String path)` Set the path to the SSL key store.
`NetClient` | `setReceiveBufferSize(int size)` Set the TCP receive buffer size for connections created by this instance to `size` in bytes.
`NetClient` | `setReconnectAttempts(int attempts)` Set the number of reconnection attempts.
`NetClient` | `setReconnectInterval(long interval)` Set the reconnect interval, in milliseconds
`NetClient` | `setReuseAddress(boolean reuse)` Set the TCP reuseAddress setting for connections created by this instance to `reuse`.
`NetClient` | `setSSL(boolean ssl)` If `ssl` is `true`, this signifies that any connections will be SSL connections.
`NetClient` | `setSendBufferSize(int size)` Set the TCP send buffer size for connections created by this instance to `size` in bytes.
`NetClient` | `setSoLinger(boolean linger)` Set the TCP soLinger setting for connections created by this instance to `linger`.
`NetClient` | `setTCPKeepAlive(boolean keepAlive)` Set the TCP keepAlive setting for connections created by this instance to `keepAlive`.
`NetClient` | `setTCPNoDelay(boolean tcpNoDelay)` If `tcpNoDelay` is set to `true` then Nagle's algorithm will turned off for the TCP connections created by this instance.
`NetClient` | `setTrafficClass(int trafficClass)` Set the TCP trafficClass setting for connections created by this instance to `trafficClass`.
`NetClient` | `setTrustAll(boolean trustAll)` If you want an SSL client to trust *all* server certificates rather than match them against those in its trust store, you can set this to true.
`NetClient` | `setTrustStorePassword(java.lang.String pwd)` Set the password for the SSL trust store.
`NetClient` | `setTrustStorePath(java.lang.String path)` Set the path to the SSL trust store.

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### jClient

    protected NetClient jClient

Method Detail

### close

    void close()

  Close the client. Any sockets which have not been closed manually will be closed here.

### connect

    NetClient connect(int port, java.lang.Object hndlr)

  Attempt to open a connection to a server at the specific `port` and host `localhost` The connect is done asynchronously and on success, a NetSocket instance is supplied via the `connectHandler` instance
  Returns:
    a reference to this so multiple method calls can be chained together

### connect

    NetClient connect(int port, java.lang.String host, groovy.lang.Closure hndlr)

  Attempt to open a connection to a server at the specific `port` and `host`. `host` can be a valid host name or IP addresss. The connect is done asynchronously and on success, a NetSocket instance is supplied via the `connectHandler` instance
  Returns:
    a reference to this so multiple method calls can be chained together

### getBossThreads

    java.lang.Integer getBossThreads()

  Returns:
    The number of boss threads

### getConnectTimeout

    java.lang.Long getConnectTimeout()

  Returns:
    The connect timeout

### getKeyStorePassword

    java.lang.String getKeyStorePassword()

  Returns:
    The keystore password

### getKeyStorePath

    java.lang.String getKeyStorePath()

  Returns:
    The path to the key store

### getReceiveBufferSize

    java.lang.Integer getReceiveBufferSize()

  Returns:
    The TCP receive buffer size

### getReconnectAttempts

    int getReconnectAttempts()

  Get the number of reconnect attempts

### getReconnectInterval

    long getReconnectInterval()

  Get the reconnect interval, in milliseconds.

### getSendBufferSize

    java.lang.Integer getSendBufferSize()

  Returns:
    The TCP send buffer size

### getTrafficClass

    java.lang.Integer getTrafficClass()

  Returns:
    the value of TCP traffic class

### getTrustStorePassword

    java.lang.String getTrustStorePassword()

  Returns:
    The trust store password

### getTrustStorePath

    java.lang.String getTrustStorePath()

  Returns:
    The trust store path

### isReuseAddress

    java.lang.Boolean isReuseAddress()

  Returns:
    The value of TCP reuse address

### isSSL

    boolean isSSL()

  Returns:
    true if this client will make SSL connections

### isSoLinger

    java.lang.Boolean isSoLinger()

  Returns:
    the value of TCP so linger

### isTCPKeepAlive

    java.lang.Boolean isTCPKeepAlive()

  Returns:
    true if TCP keep alive is enabled

### isTCPNoDelay

    java.lang.Boolean isTCPNoDelay()

  Returns:
    true if Nagle's algorithm is disabled.

### setBossThreads

    NetClient setBossThreads(long threads)

  Set the number of boss threads to use. Boss threads are used to make connections.
  Returns:
    a reference to this so multiple method calls can be chained together

### setConnectTimeout

    NetClient setConnectTimeout(long timeout)

  Set the connect timeout in milliseconds
  Returns:
    a reference to this so multiple method calls can be chained together

### setKeyStorePassword

    NetClient setKeyStorePassword(java.lang.String pwd)

  Set the password for the SSL key store. This method should only be used in SSL mode, i.e. after setSSL(boolean) has been set to `true`.

  Returns:
    A reference to this, so multiple invocations can be chained together.

### setKeyStorePath

    NetClient setKeyStorePath(java.lang.String path)

  Set the path to the SSL key store. This method should only be used in SSL mode, i.e. after 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.

  Returns:
    A reference to this, so multiple invocations can be chained together.

### setReceiveBufferSize

    NetClient setReceiveBufferSize(int size)

  Set the TCP receive buffer size for connections created by this instance to `size` in bytes.
  Returns:
    a reference to this so multiple method calls can be chained together

### setReconnectAttempts

    NetClient setReconnectAttempts(int attempts)

  Set the number of reconnection attempts. In the event a connection attempt fails, the client will attempt to connect a further number of times, before it fails. Default value is zero.

### setReconnectInterval

    NetClient setReconnectInterval(long interval)

  Set the reconnect interval, in milliseconds

### setReuseAddress

    NetClient setReuseAddress(boolean reuse)

  Set the TCP reuseAddress setting for connections created by this instance to `reuse`.
  Returns:
    a reference to this so multiple method calls can be chained together

### setSSL

    NetClient setSSL(boolean ssl)

  If `ssl` is `true`, this signifies that any connections will be SSL connections.
  Returns:
    A reference to this, so multiple invocations can be chained together.

### setSendBufferSize

    NetClient setSendBufferSize(int size)

  Set the TCP send buffer size for connections created by this instance to `size` in bytes.
  Returns:
    a reference to this so multiple method calls can be chained together

### setSoLinger

    NetClient setSoLinger(boolean linger)

  Set the TCP soLinger setting for connections created by this instance to `linger`.
  Returns:
    a reference to this so multiple method calls can be chained together

### setTCPKeepAlive

    NetClient setTCPKeepAlive(boolean keepAlive)

  Set the TCP keepAlive setting for connections created by this instance to `keepAlive`.
  Returns:
    a reference to this so multiple method calls can be chained together

### setTCPNoDelay

    NetClient setTCPNoDelay(boolean tcpNoDelay)

  If `tcpNoDelay` is set to `true` then Nagle's algorithm will turned off for the TCP connections created by this instance.
  Returns:
    a reference to this so multiple method calls can be chained together

### setTrafficClass

    NetClient setTrafficClass(int trafficClass)

  Set the TCP trafficClass setting for connections created by this instance to `trafficClass`.
  Returns:
    a reference to this so multiple method calls can be chained together

### setTrustAll

    NetClient setTrustAll(boolean trustAll)

  If you want an SSL client to trust *all* server certificates rather than match them against those in its trust store, you can set this to true.

  Use this with caution as you may be exposed to "main in the middle" attacks

  Parameters:
    `trustAll` - Set to true if you want to trust all server certificates

### setTrustStorePassword

    NetClient setTrustStorePassword(java.lang.String pwd)

  Set the password for the SSL trust store. This method should only be used in SSL mode, i.e. after setSSL(boolean) has been set to `true`.

  Returns:
    A reference to this, so multiple invocations can be chained together.

### setTrustStorePath

    NetClient setTrustStorePath(java.lang.String path)

  Set the path to the SSL trust store. This method should only be used in SSL mode, i.e. after 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. If you wish the client to trust all server certificates you can use the setTrustAll(boolean) method.

  Returns:
    A reference to this, so multiple invocations can be chained together.

Groovy Documentation