aboutsummaryrefslogtreecommitdiff
path: root/core/net/socket_linux.odin
diff options
context:
space:
mode:
authorPePerRoNii <wachiraphol.yin@gmail.com>2025-06-11 13:10:37 +0700
committerPePerRoNii <wachiraphol.yin@gmail.com>2025-06-11 13:10:37 +0700
commita32ee6af97459ef9cf1f52df4f522a30abadec04 (patch)
tree6dcdea17a321bb65d3e571089f4c4a3d3483e716 /core/net/socket_linux.odin
parent297fdd4075c18c8102ef7a453bc10675cccef3a5 (diff)
added linux implementation NOTE: tcp_recv_error doesn't cover all cases
Diffstat (limited to 'core/net/socket_linux.odin')
-rw-r--r--core/net/socket_linux.odin13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin
index 3ec3521f0..b176fb848 100644
--- a/core/net/socket_linux.odin
+++ b/core/net/socket_linux.odin
@@ -231,6 +231,19 @@ _bound_endpoint :: proc(sock: Any_Socket) -> (ep: Endpoint, err: Listen_Error) {
}
@(private)
+_peer_endpoint :: proc(sock: Any_Socket) -> (ep: Endpoint, err: TCP_Recv_Error) {
+ addr: linux.Sock_Addr_Any
+ errno := linux.getpeername(_unwrap_os_socket(sock), &addr)
+ if errno != .NONE {
+ err = _tcp_recv_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: Accept_Error) {
addr: linux.Sock_Addr_Any
client_sock, errno := linux.accept(linux.Fd(sock), &addr)