- All Superinterfaces:
AutoCloseable
,Closeable
One established connection.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSocketListener
(SocketListener listener, boolean synchronous) void
close()
Closing a socket also removes it from its context.Gets the time this connection closed or null if still connected.Gets the remote address at connection time.long
Gets the time this connection was established.getId()
Gets this socket's unique identifier.Gets the protocol, such as "http" or "tcp".Gets the most recently seen remote address.Gets the context this socket is running within.boolean
isClosed()
Checks if this socket is closed.boolean
removeSocketListener
(SocketListener listener) void
sendMessage
(Message message) Sends a single message.void
sendMessages
(Collection<? extends Message> messages) Sends a set of messages.void
Starts the I/O of a socket.
-
Method Details
-
getSocketContext
SocketContext getSocketContext()Gets the context this socket is running within. -
getId
Identifier getId()Gets this socket's unique identifier. This identifier should remain secret as compromising an identifier may allow hijacking a connection. No two sockets will have the same identifier for a given context at the same time. -
getConnectTime
long getConnectTime()Gets the time this connection was established. -
getCloseTime
Long getCloseTime()Gets the time this connection closed or null if still connected. -
getProtocol
String getProtocol()Gets the protocol, such as "http" or "tcp". -
getConnectRemoteSocketAddress
SocketAddress getConnectRemoteSocketAddress()Gets the remote address at connection time. This value will not change. -
getRemoteSocketAddress
SocketAddress getRemoteSocketAddress()Gets the most recently seen remote address. This value may change. -
start
void start(Callback<? super Socket> onStart, Callback<? super Throwable> onError) throws IllegalStateException Starts the I/O of a socket. After connection, a socket does not send I/O events until started. This allows listeners to be registered between connect and start calls.- Throws:
IllegalStateException
- if closed or already started
-
close
Closing a socket also removes it from its context.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isClosed
boolean isClosed()Checks if this socket is closed. -
addSocketListener
- Throws:
IllegalStateException
-
removeSocketListener
-
sendMessage
Sends a single message. This will never block.- Throws:
IllegalStateException
- if this socket is closed
-
sendMessages
Sends a set of messages. This will never block. If messages is empty, the request is ignored.- Throws:
IllegalStateException
- if this socket is closed
-