Skip to main content

patch_seq_tcp_local_port

Function patch_seq_tcp_local_port 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn patch_seq_tcp_local_port( stack: Stack, ) -> Stack
Expand description

Get the local port a Socket is bound to.

Stack effect: ( Socket -- Int Bool )

Works on both listeners (returns the port from net.tcp.listen, useful when 0 was passed to let the OS pick) and connected streams (returns the ephemeral local port the kernel chose for the connection). For TLS-wrapped sockets, returns the underlying TCP local port.

Returns (0, false) when the socket id is invalid or the OS can’t report the local address.

§Safety

Stack must have an Int (socket_id) on top.