Class TcpTransport
java.lang.Object
ai.badmonkey.agentspaces.peering.transport.TcpTransport
- All Implemented Interfaces:
Transport
-
Nested Class Summary
Nested classes/interfaces inherited from interface Transport
Transport.Capability -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOpens a connection to a peer address.listen(String bindAddress, Consumer<TransportConnection> onAccept) Starts listening for inbound connections.static InetSocketAddressReturns the local port a listener handle is bound to; helper for tests and demos.scheme()Returns the transport scheme, e.g.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Transport
capabilities, dial
-
Constructor Details
-
TcpTransport
public TcpTransport()
-
-
Method Details
-
scheme
-
dial
Description copied from interface:TransportOpens a connection to a peer address.- Specified by:
dialin interfaceTransport- Parameters:
address- a transport-specific address- Returns:
- the open connection
- Throws:
IOException- if the peer cannot be reached
-
listen
public AutoCloseable listen(String bindAddress, Consumer<TransportConnection> onAccept) throws IOException Description copied from interface:TransportStarts listening for inbound connections.- Specified by:
listenin interfaceTransport- Parameters:
bindAddress- a transport-specific bind addressonAccept- invoked for each accepted connection- Returns:
- a handle that stops listening when closed
- Throws:
IOException- if the address cannot be bound
-
parse
Returns the local port a listener handle is bound to; helper for tests and demos.
-