Creates SocketAddress instances, returning them through a Promise.
| Modifier and Type | Class and Description |
|---|---|
| public static class | SocketAddressResolver.Async
Creates |
| public static class | SocketAddressResolver.Sync
Creates |
| Modifier and Type | Method and Description |
|---|---|
| public void | resolve(String
the host to resolve host, int the port of the resulting socket address port, Promise<List<InetSocketAddress>> the callback invoked when the resolution succeeds or fails promise)Resolves via DNS the given host and port, within the connect timeout,
returning a list of |
| resolve | back to summary |
|---|---|
| public void resolve(String host, int port, Promise<List<InetSocketAddress>> promise) Resolves via DNS the given host and port, within the connect timeout,
returning a list of
| |
Creates InetSocketAddress instances asynchronously in a different thread.
InetSocketAddress#InetSocketAddress(String, int) attempts to perform a DNS
resolution of the host name, and this may block for several seconds.
This class creates the InetSocketAddress in a separate thread and provides the result
through a Promise, with the possibility to specify a timeout for the operation.
Example usage:
SocketAddressResolver resolver = new SocketAddressResolver.Async(executor, scheduler, timeout);
resolver.resolve("www.google.com", 80, new Promise<SocketAddress>()
{
public void succeeded(SocketAddress result)
{
// The address was resolved
}
public void failed(Throwable failure)
{
// The address resolution failed
}
});
| Modifier and Type | Field and Description |
|---|---|
| private final Executor | |
| private static final Logger | |
| private final Scheduler | |
| private final long |
| Access | Constructor and Description |
|---|---|
| public | Async(Executor
the thread pool to use to perform DNS resolution in pooled threads executor, Scheduler the scheduler to schedule tasks to cancel DNS resolution if it takes too long scheduler, long the timeout, in milliseconds, for the DNS resolution to complete timeout)Creates a new instance with the given executor (to perform DNS resolution in a separate thread), the given scheduler (to cancel the operation if it takes too long) and the given timeout, in milliseconds. |
| Modifier and Type | Method and Description |
|---|---|
| public Executor | |
| public Scheduler | |
| public long | |
| public void | resolve(final String
the host to resolve host, final int the port of the resulting socket address port, final Promise<List<InetSocketAddress>> the callback invoked when the resolution succeeds or fails promise)Implements org. InetSocketAddress through the given Promise.
|
| executor | back to summary |
|---|---|
| private final Executor executor | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| scheduler | back to summary |
|---|---|
| private final Scheduler scheduler | |
| timeout | back to summary |
|---|---|
| private final long timeout | |
| Async | back to summary |
|---|---|
| public Async(Executor executor, Scheduler scheduler, long timeout) Creates a new instance with the given executor (to perform DNS resolution in a separate thread), the given scheduler (to cancel the operation if it takes too long) and the given timeout, in milliseconds. | |
| getExecutor | back to summary |
|---|---|
| public Executor getExecutor() | |
| getScheduler | back to summary |
|---|---|
| public Scheduler getScheduler() | |
| getTimeout | back to summary |
|---|---|
public long getTimeout()
| |
| resolve | back to summary |
|---|---|
| public void resolve(final String host, final int port, final Promise<List<InetSocketAddress>> promise) Implements org. Doc from org. Resolves via DNS the given host and port, within the connect timeout,
returning a list of
| |
Creates InetSocketAddress instances synchronously in the caller thread.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | resolve(String
the host to resolve host, int the port of the resulting socket address port, Promise<List<InetSocketAddress>> the callback invoked when the resolution succeeds or fails promise)Implements org. InetSocketAddress through the given Promise.
|
| Sync | back to summary |
|---|---|
| public Sync() | |
| resolve | back to summary |
|---|---|
| public void resolve(String host, int port, Promise<List<InetSocketAddress>> promise) Implements org. Doc from org. Resolves via DNS the given host and port, within the connect timeout,
returning a list of
| |