Package com.ngrok
Interface Connection
-
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
Connection.Edge
,Connection.Endpoint
public interface Connection extends AutoCloseable
Represents a connection established over a listener.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Connection.Edge
Represents a connection established over an edge listenerstatic interface
Connection.Endpoint
Represents a connection establish over an endpoint listener.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Closes this connection and releases any system resources associated with it.String
getRemoteAddr()
Returns the remote address that established this connection.default InetSocketAddress
inetAddress()
Creates anInetSocketAddress
for this connection's remote address.int
read(ByteBuffer dst)
Reads the next available bytes from this connection, up to the buffer capacity.int
write(ByteBuffer src)
Writes a sequence of bytes to this connection from the given buffer.
-
-
-
Method Detail
-
getRemoteAddr
String getRemoteAddr()
Returns the remote address that established this connection.- Returns:
- an internet address, in IP:port form
-
inetAddress
default InetSocketAddress inetAddress()
Creates anInetSocketAddress
for this connection's remote address.- Returns:
InetSocketAddress
representing the internet address
-
read
int read(ByteBuffer dst) throws IOException
Reads the next available bytes from this connection, up to the buffer capacity.- Parameters:
dst
- the buffer to read bytes into- Returns:
- the number of bytes read, or -1 if the end of the stream has been reached
- Throws:
IOException
- if an I/O error occurs
-
write
int write(ByteBuffer src) throws IOException
Writes a sequence of bytes to this connection from the given buffer.- Parameters:
src
- the buffer containing bytes to write- Returns:
- the number of bytes written
- Throws:
IOException
- if an I/O error occurs
-
close
void close() throws IOException
Closes this connection and releases any system resources associated with it.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- if an I/O error occurs
-
-