net: make close/0, select/2 and remote/0 methods of UdpSocket pub (#24004)

This commit is contained in:
larpon 2025-03-22 15:41:32 +01:00 committed by GitHub
parent 1c1eb462e7
commit 20d7d9758b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}