Browse files

python: add more bindings for SockAddr

  • Loading branch information...
aberaud committed Dec 24, 2018
1 parent 592ed4e commit 0066be49b90396114442104c9247f6c9974c5c23
Showing with 10 additions and 1 deletion.
  1. +6 −0 python/opendht.pyx
  2. +3 −0 python/opendht_cpp.pxd
  3. +1 −1 python/tools/
@@ -139,6 +139,12 @@ cdef class SockAddr(object):
return self._addr.setPort(port)
def setFamily(SockAddr self, cpp.sa_family_t af):
return self._addr.setFamily(af)
def isLoopback(SockAddr self):
return self._addr.isLoopback()
def isPrivate(SockAddr self):
return self._addr.isPrivate()
def isUnspecified(SockAddr self):
return self._addr.isUnspecified()
def __str__(self):
return self.toString().decode()
def __repr__(self):
@@ -77,6 +77,9 @@ cdef extern from "opendht/sockaddr.h" namespace "dht":
void setPort(in_port_t p)
sa_family_t getFamily() const
void setFamily(sa_family_t f)
bool isLoopback() const
bool isPrivate() const
bool isUnspecified() const

ctypedef vector[uint8_t] Blob

@@ -51,7 +51,7 @@ def ping(node, h):

def pong(node, h):
print(node.getNodeId().decode(), "got ping", h, i)
loop.call_soon_threadsafe(ping, node, h);
loop.call_soon_threadsafe(ping, node, h)
return True

ping_node.listen(loc_ping, lambda v: pong(pong_node, loc_pong))

0 comments on commit 0066be4

Please sign in to comment.