From 20d7d9758ba5df723dca50cdcb352b27107658e1 Mon Sep 17 00:00:00 2001 From: larpon <768942+larpon@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:41:32 +0100 Subject: [PATCH] net: make `close/0`, `select/2` and `remote/0` methods of `UdpSocket` `pub` (#24004) --- vlib/net/udp.c.v | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vlib/net/udp.c.v b/vlib/net/udp.c.v index 1b0e1923e0..4683902ae6 100644 --- a/vlib/net/udp.c.v +++ b/vlib/net/udp.c.v @@ -274,18 +274,21 @@ pub fn (mut s UdpSocket) set_dualstack(on bool) ! { sizeof(int)))! } -fn (mut s UdpSocket) close() ! { +// close shuts down and closes the socket for communication. +pub fn (mut s UdpSocket) close() ! { shutdown(s.handle) return close(s.handle) } -fn (mut s UdpSocket) select(test Select, timeout time.Duration) !bool { +// select waits for no more than `timeout` for the IO operation, defined by `test`, to be available. +pub fn (mut s UdpSocket) select(test Select, timeout time.Duration) !bool { return select(s.handle, test, timeout) } -fn (s &UdpSocket) remote() !Addr { +// remote returns the remote `Addr` address of the socket or `none` if no remote is has been resolved. +pub fn (s &UdpSocket) remote() ?Addr { if s.has_r { return s.r } - return error('none') + return none }