def add_usock(self): epoll = pyudt.Epoll() socket = pyudt.Socket() try: epoll.add_usock(socket) except: self.fail('Error in Epoll.add_usock')
def threaded_server(): # Create a UDT socket to simulate a server s_server = pyudt.Socket() s_server.bind('127.0.0.1', 4444) s_server.listen(100) # Create an epoll e = pyudt.Epoll() # Accept incoming connections client, addr = s_server.accept() # Add the client sockets to the epoll e.add_usock(client, pyudt.UDT_EPOLL_IN) # Ask the epoll to wait for events for 10ms e.wait(10, True, False, True, False) # Receive data from the client test_data_rcv = client.recv(test_data_len) print 'Received message: ' + str(test_data_rcv[0:test_data_len]) # Garbage collect closed/broken sockets e.garbage_collect() # Remove client socket from epoll e.remove_usock(client) # Close server socket s_server.close()
def add_usock_flags(self): epoll = pyudt.Epoll() socket = pyudt.Socket() try: epoll.add_usock(socket, pyudt.UDT_EPOLL_IN) except: self.fail('Error in Epoll.add_usock\n' + str(sys.exc_info()[1]))
def add_ssock(self): epoll = pyudt.Epoll() socket = socklib.socket() try: epoll.add_ssock(socket) except: self.fail('Error in Epoll.add_ssock\n' + str(sys.exc_info()[1]))
def destruction(self): epoll = pyudt.Epoll() try: del epoll except: self.fail('Error during epoll destruction\n' + str(sys.exc_info()[1]))
def garbage_collect(self): epoll = pyudt.Epoll() try: epoll.garbage_collect() except: self.fail('Error in Epoll.garbage_collect\n' + str(sys.exc_info()[1]))
def remove_usock(self): epoll = pyudt.Epoll() socket = pyudt.Socket() try: epoll.add_usock(socket) epoll.remove_usock(socket) except: self.fail('Error in Epoll.remove_usock\n' + str(sys.exc_info()[1]))
def get_read_udt(self): epoll = pyudt.Epoll() socket = pyudt.Socket() epoll.add_usock(socket) try: res = epoll.get_read_udt() except: self.fail('Error in Epoll.get_read_udt:\n' + str(sys.exc_info()[1]))
def destruction(self): epoll = pyudt.Epoll() try: del epoll except: self.fail('Error during epoll destruction')
def creation(self): epoll = pyudt.Epoll() assert epoll != None
def get_id(self): epoll = pyudt.Epoll() assert epoll.id() != 0