Exemple #1
0
    def __init__(self, family=NETLINK_GENERIC, groups=0):
        """
        Create and bind socket structure
        """
        self.fd = libc.socket(AF_NETLINK,SOCK_RAW,family)

        sa = sockaddr()
        sa.family = AF_NETLINK
        sa.pid = getpid()
        sa.groups = groups

        l = libc.bind(self.fd, byref(sa), sizeof(sa))
        if l != 0:
            self.close()
            raise Exception("libc.bind(): errcode %i" % (l))
Exemple #2
0
    def __init__(self, address='0.0.0.0',port=10001):
        """
        Create and bind socket structure
        """
        self.fd = libc.socket(AF_INET,SOCK_STREAM,0)
        libc.setsockopt(self.fd, SOL_SOCKET, SO_REUSEADDR, byref(c_uint32(1)), sizeof(c_uint32))

        sa = sockaddr_in()
        sa.sin_family = AF_INET
        sa.sin_port = htons(port)
        sa.sin_addr = htonl(dqn_to_int(address))

        self.sa = sa

        l = libc.bind(self.fd, byref(sa), sizeof(sa))
        if l != 0:
            self.close()
            raise Exception("libc.bind(): errcode %i" % (l))
Exemple #3
0
    def __init__(self, address='0.0.0.0', port=10001):
        """
        Create and bind socket structure
        """
        self.fd = libc.socket(AF_INET, SOCK_STREAM, 0)
        libc.setsockopt(self.fd, SOL_SOCKET, SO_REUSEADDR, byref(c_uint32(1)),
                        sizeof(c_uint32))

        sa = sockaddr_in()
        sa.sin_family = AF_INET
        sa.sin_port = htons(port)
        sa.sin_addr = htonl(dqn_to_int(address))

        self.sa = sa

        l = libc.bind(self.fd, byref(sa), sizeof(sa))
        if l != 0:
            self.close()
            raise Exception("libc.bind(): errcode %i" % (l))

        for i in range(QTHREADS):
            p9socketworker(self).start()