Skip to content
ListenerLocalAddr

ListenerLocalAddr

Description

Query the actually-bound local address of a listener. Useful after ListenerOpen with port 0, where the kernel picks the port. Wraps getsockname on POSIX / Winsock identically.

Parameters

Name Direction Description
self in Open listener.
out out Filled with the bound address. Zeroed on failure.

Success

returns true; out populated.

Failure

returns false; logs the failing syscall.

Usage example (Cross-references)

Usage examples (Cross-references)
        // public API.
        SocketAddr local;
        if (!ListenerLocalAddr(&listener, &local)) {
            ListenerClose(&listener);
            DefaultAllocatorDeinit(&alloc);
    }
    
    bool ListenerLocalAddr(const Listener *self, SocketAddr *out) {
        if (!self || !out) {
            LOG_ERROR("ListenerLocalAddr: NULL argument");
    bool ListenerLocalAddr(const Listener *self, SocketAddr *out) {
        if (!self || !out) {
            LOG_ERROR("ListenerLocalAddr: NULL argument");
            return false;
        }
Last updated on