import threading
import time
import socket


class ThreadServer (threading.Thread):
    def __init__(self, ipMask, port):
        threading.Thread.__init__(self)
        self.server_socket = socket.socket()
        self.server_socket.bind((ipMask, port))
        self.connection = self.server_socket.accept()[0].makefile('rb')

    def runserver(self):
        self.server_socket.listen(0)
        print('runing')

    def closeserver(self):
        self.connection.close()
        self.server_socket.close()
