Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)

        def unpack_hostport(addr):
    if len(addr) == 6:
        host = addr[:4]
        port = addr[4:6]
    if len(addr) == 18:
        host = addr[:16]
        port = addr[16:18]
    return (unpack_host(host), unpack_port(port))
        


src/d/h/dhtfck-HEAD/btdht/btdht.py   dhtfck(Download)
from .bencode import bdecode, BTFailure
from .node import Node
from .utils import decode_nodes, encode_nodes, random_node_id, unpack_host, unpack_hostport
 
logger = logging.getLogger(__name__)
                values = args["values"]
                for addr in values:
                    hp = unpack_hostport(addr)
                    self.server.dht.ht.add_peer(info_hash, hp)
                    logger.debug("Got new peer for %s: %r" % (info_hash.encode("hex"), hp))

src/d/h/DHT-woodworm-HEAD/btdht/btdht.py   DHT-woodworm(Download)
from .bencode import bdecode, BTFailure
from .node import Node
from .utils import decode_nodes, encode_nodes, random_node_id, unpack_host, unpack_hostport
 
 
                values = args["values"]
                for addr in values:
                    hp = unpack_hostport(addr)
                    self.server.dht.ht.add_peer(info_hash, hp)
                    logger.debug("Got new peer for %s: %r" % (info_hash.encode("hex"), hp))