from threading import Thread from SocketServer import ThreadingMixIn import io import socket import struct from PIL import Image image_index = 1 TCP_IP = '0.0.0.0' TCP_PORT = 9001 BUFFER_SIZE = 1024 class ClientThread(Thread): #def __init__(self,ip,port,sock): def __init__(self,sock, image_index): Thread.__init__(self) #self.ip = ip #self.port = port self.sock = sock self.image_index = image_index #print " New thread started for "+ip+":"+str(port) def run(self): while True: # Read the length of the image as a 32-bit unsigned int. If the # length is zero, quit the loop image_len = struct.unpack('