connect() — netty Function Reference
Architecture documentation for the connect() function in LocalChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 138997d1_ae4b_899e_69a4_f393e357ad1f["connect()"] 84d2a0d7_132c_c9dd_926c_de7389277737["LocalUnsafe"] 138997d1_ae4b_899e_69a4_f393e357ad1f -->|defined in| 84d2a0d7_132c_c9dd_926c_de7389277737 64c2356a_7595_21cb_3c1f_5ea823bfa144["LocalAddress()"] 138997d1_ae4b_899e_69a4_f393e357ad1f -->|calls| 64c2356a_7595_21cb_3c1f_5ea823bfa144 60014652_5e69_eacb_7bce_6e56bfdfeb05["doBind()"] 138997d1_ae4b_899e_69a4_f393e357ad1f -->|calls| 60014652_5e69_eacb_7bce_6e56bfdfeb05 19db0fc8_1524_a49b_2c8e_8b165b94bc06["close()"] 138997d1_ae4b_899e_69a4_f393e357ad1f -->|calls| 19db0fc8_1524_a49b_2c8e_8b165b94bc06 style 138997d1_ae4b_899e_69a4_f393e357ad1f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/local/LocalChannel.java lines 538–584
@Override
public void connect(final SocketAddress remoteAddress,
SocketAddress localAddress, final ChannelPromise promise) {
if (!promise.setUncancellable() || !ensureOpen(promise)) {
return;
}
if (state == State.CONNECTED) {
Exception cause = new AlreadyConnectedException();
safeSetFailure(promise, cause);
return;
}
if (connectPromise != null) {
throw new ConnectionPendingException();
}
connectPromise = promise;
if (state != State.BOUND) {
// Not bound yet and no localAddress specified - get one.
if (localAddress == null) {
localAddress = new LocalAddress(LocalChannel.this);
}
}
if (localAddress != null) {
try {
doBind(localAddress);
} catch (Throwable t) {
safeSetFailure(promise, t);
close(voidPromise());
return;
}
}
Channel boundChannel = LocalChannelRegistry.get(remoteAddress);
if (!(boundChannel instanceof LocalServerChannel)) {
Exception cause = new ConnectException("connection refused: " + remoteAddress);
safeSetFailure(promise, cause);
close(voidPromise());
return;
}
LocalServerChannel serverChannel = (LocalServerChannel) boundChannel;
peer = serverChannel.serve(LocalChannel.this);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does connect() do?
connect() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/local/LocalChannel.java.
Where is connect() defined?
connect() is defined in transport/src/main/java/io/netty/channel/local/LocalChannel.java at line 538.
What does connect() call?
connect() calls 3 function(s): LocalAddress, close, doBind.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free