fix Socket.get_option calling setsockopt instead of getsockopt (#2421)

* fix Socket.get_option

* `Socket.get_option` didn't properly call `getsockopt`, and `getsockopt` had an invalid signature.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Book-reader
2025-08-19 21:36:18 +12:00
committed by GitHub
parent 551ce34b9b
commit 18b4ce4e7d
3 changed files with 33 additions and 2 deletions

View File

@@ -116,7 +116,8 @@ fn void? Socket.set_option(&self, SocketOption option, bool value)
fn bool? Socket.get_option(&self, SocketOption option)
{
CInt flag;
int errcode = os::setsockopt(self.sock, os::SOL_SOCKET, option.value, &flag, CInt.sizeof);
Socklen_t socklen = CInt.sizeof;
int errcode = os::getsockopt(self.sock, os::SOL_SOCKET, option.value, &flag, &socklen);
if (errcode != 0) return SOCKOPT_FAILED?;
return (bool)flag;
}