diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-09-19 12:53:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-19 12:53:42 +0100 |
| commit | 327ca2ab717ae288e74bbedd768f252770159470 (patch) | |
| tree | 70257c863cd84f7cdda6af27ed9c655afa2db959 /core/net/socket_linux.odin | |
| parent | 68960e7d0a3cc9a0c3c8a7f5589ae5c0e5a966f1 (diff) | |
| parent | 652557bfcd64deccf018e96817a001fd9c4d69a1 (diff) | |
Merge pull request #4261 from laytan/net-bound-endpoint
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 27d3359b5..a3853874a 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) |