Io module

local_address

procedure · 2 overloadsSource

The address this socket is bound to; with tcp_listen(":0"), which port it got.

Example
Io :: #import "Extensions/Io";

main :: () {
    Io.io_run(() {
        listener, _ := Io.tcp_listen("127.0.0.1:0");
        defer Io.close(listener);

        address, error := Io.local_address(listener);
        assert(error == .NONE);
        assert(address.family == .IPV4 && address.port != 0);
    });
}

Doesn't run in the browser (skipped on wasm).

local_address :: (listener: Tcp_Listener) -> (Address, Io_Error)

The address this socket is bound to; with tcp_listen(":0"), which port it got.

Parameters

listener: Tcp_Listener

Returns

Example
Io :: #import "Extensions/Io";

main :: () {
    Io.io_run(() {
        listener, _ := Io.tcp_listen("127.0.0.1:0");
        defer Io.close(listener);

        address, error := Io.local_address(listener);
        assert(error == .NONE);
        assert(address.family == .IPV4 && address.port != 0);
    });
}

Doesn't run in the browser (skipped on wasm).

local_address :: (stream: Tcp_Stream) -> (Address, Io_Error)

The local end of a connected stream: the address and port this side of the connection uses.

Parameters

stream: Tcp_Stream

Returns

See also