public interface SocketConnector extends AutoCloseable
| Modifier and Type | Interface and Description |
|---|---|
static class |
SocketConnector.ErrorReason
An enum that defines reasons for socket connecting errors.
|
static interface |
SocketConnector.Listener
The interface represents a listener for handling connect events.
|
| Modifier and Type | Field and Description |
|---|---|
static SocketConnector.Listener |
NULL_LISTENER
This field represents a dummy implementation of the
SocketConnector.Listener interface. |
| Modifier and Type | Method and Description |
|---|---|
Socket |
connect()
Synchronous connection attempt.
|
void |
connectAfterInterval(long interval,
TimeUnit timeUnit)
Initiates a connection attempt after a specified interval.
|
void |
connectAsync()
Initiates an asynchronous connection attempt.
|
String |
getHost()
Returns the hostname or IP address to connect.
|
int |
getPort()
Returns the port number to connect.
|
void |
setListener(SocketConnector.Listener listener)
Sets the listener for this socket connector.
|
void |
stopConnectAfterInterval()
Stops a previously scheduled connection attempt via
connectAfterInterval(long, TimeUnit). |
closestatic final SocketConnector.Listener NULL_LISTENER
SocketConnector.Listener interface.String getHost()
int getPort()
void setListener(SocketConnector.Listener listener)
listener - the listener to use for connection eventsSocket connect() throws IOException
IOException - if an error occurs during the binding/connection.void connectAsync()
void connectAfterInterval(long interval,
TimeUnit timeUnit)
interval - the length of the intervaltimeUnit - the time unit for the intervalvoid stopConnectAfterInterval()
connectAfterInterval(long, TimeUnit).Copyright © 2014–2025 Onix Solutions. All rights reserved.