diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-09-17 22:22:19 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-09-17 22:22:19 +0200 |
| commit | 652557bfcd64deccf018e96817a001fd9c4d69a1 (patch) | |
| tree | 0f2ba9b19523fd200dcdaaa709b4383f4118a7e6 /core/net/socket_linux.odin | |
| parent | 6ef779cd5c8260b2e6979e676d28489fd53dd599 (diff) | |
net: add `bound_endpoint` procedure
Diffstat (limited to 'core/net/socket_linux.odin')
| -rw-r--r-- | core/net/socket_linux.odin | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin index 52f328814..b630c8f1b 100644 --- a/core/net/socket_linux.odin +++ b/core/net/socket_linux.odin @@ -203,6 +203,19 @@ _listen_tcp :: proc(endpoint: Endpoint, backlog := 1000) -> (TCP_Socket, Network } @(private) +_bound_endpoint :: proc(sock: Any_Socket) -> (ep: Endpoint, err: Network_Error) { + addr: linux.Sock_Addr_Any + errno := linux.getsockname(_unwrap_os_socket(sock), &addr) + if errno != .NONE { + err = Listen_Error(errno) + return + } + + ep = _wrap_os_addr(addr) + return +} + +@(private) _accept_tcp :: proc(sock: TCP_Socket, options := default_tcp_options) -> (tcp_client: TCP_Socket, endpoint: Endpoint, err: Network_Error) { addr: linux.Sock_Addr_Any client_sock, errno := linux.accept(linux.Fd(sock), &addr) |