Skip to content

Commit 8704545

Browse files
Copilotmindflayer
andcommitted
Fix setsockopt signature to match standard socket API
Co-authored-by: mindflayer <527325+mindflayer@users.noreply.github.com>
1 parent 5ac9ac9 commit 8704545

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

mocket/socket.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,26 @@ def gettimeout(self) -> float | None:
225225
"""
226226
return self._timeout
227227

228-
def setsockopt(self, family: int, type: int, proto: int) -> None:
229-
"""Set socket options.
228+
def setsockopt(
229+
self,
230+
level: int,
231+
optname: int,
232+
value: int | bytes | None,
233+
optlen: int | None = None,
234+
) -> None:
235+
"""Set socket option.
230236
231237
Args:
232-
family: Address family
233-
type: Socket type
234-
proto: Protocol number
238+
level: Socket option level (e.g., socket.SOL_SOCKET)
239+
optname: Socket option name (e.g., socket.SO_REUSEADDR)
240+
value: Option value as an integer or bytes, or None when optlen is provided
241+
optlen: Option length (used when value is None)
235242
"""
236-
self._family = family
237-
self._type = type
238-
self._proto = proto
239-
240243
if self._true_socket:
241-
self._true_socket.setsockopt(family, type, proto)
244+
if optlen is not None:
245+
self._true_socket.setsockopt(level, optname, value, optlen)
246+
else:
247+
self._true_socket.setsockopt(level, optname, value)
242248

243249
def settimeout(self, timeout: float | None) -> None:
244250
"""Set the socket timeout.

0 commit comments

Comments
 (0)