Skip to content

Commit

Permalink
fix: add getpeername()
Browse files Browse the repository at this point in the history
  • Loading branch information
namuyan committed Aug 18, 2020
1 parent ac65e4b commit ed9f490
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions srudp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,15 @@ def setblocking(self, flag: bool) -> None:
"""change inner receiver's instead"""
self.receiver_buffer.setblocking(flag)

def getpeername(self) -> _Address:
"""connection info or raise OSError"""
if self.is_closed:
raise OSError("socket is closed")
elif self.address is None:
raise OSError("not found peer connection")
else:
return self.address

@property
def is_closed(self) -> bool:
if self.fileno() == -1:
Expand Down

0 comments on commit ed9f490

Please sign in to comment.