MCPcopy
hub / github.com/nats-io/nats.go / LocalAddr

Method LocalAddr

nats.go:2547–2559  ·  view source on GitHub ↗

LocalAddr returns the local network address of the connection

()

Source from the content-addressed store, hash-verified

2545
2546// LocalAddr returns the local network address of the connection
2547func (nc *Conn) LocalAddr() string {
2548 if nc == nil {
2549 return _EMPTY_
2550 }
2551
2552 nc.mu.RLock()
2553 defer nc.mu.RUnlock()
2554
2555 if nc.status != CONNECTED {
2556 return _EMPTY_
2557 }
2558 return nc.conn.LocalAddr().String()
2559}
2560
2561// ConnectedServerId reports the connected server's Id
2562func (nc *Conn) ConnectedServerId() string {

Callers 1

TestLocalAddrFunction · 0.95

Calls 1

StringMethod · 0.45

Tested by 1

TestLocalAddrFunction · 0.76