MCPcopy
hub / github.com/python-trio/trio / getsockname

Method getsockname

src/trio/testing/_fake_net.py:392–400  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

390 ################################################################
391
392 def getsockname(self) -> tuple[str, int] | tuple[str, int, int, int]:
393 self._check_closed()
394 if self._binding is not None:
395 return self._binding.local.as_python_sockaddr()
396 elif self.family == trio.socket.AF_INET:
397 return ("0.0.0.0", 0)
398 else:
399 assert self.family == trio.socket.AF_INET6
400 return ("::", 0)
401
402 # TODO: This method is not tested, and seems to make incorrect assumptions. It should maybe raise NotImplementedError.
403 def getpeername(self) -> tuple[str, int] | tuple[str, int, int, int]:

Callers 15

test_basic_udpFunction · 0.45
test_msg_truncFunction · 0.45
test_recv_methodsFunction · 0.45
test_initFunction · 0.45
test_SocketStream_basicsFunction · 0.45
test_SocketListenerFunction · 0.45

Calls 2

_check_closedMethod · 0.95
as_python_sockaddrMethod · 0.80

Tested by 15

test_basic_udpFunction · 0.36
test_msg_truncFunction · 0.36
test_recv_methodsFunction · 0.36
test_initFunction · 0.36
test_SocketStream_basicsFunction · 0.36
test_SocketListenerFunction · 0.36