import socket
import struct
import time
import threading

value = 0

class ClientHandler(threading.Thread):

    def __init__(self, client):
        threading.Thread.__init__(self)
        self.client_sock, self.client_addr = client

    def run(self):

        global value

        while True:
            value = int(struct.unpack('>H', self.client_sock.recv(struct.calcsize('>H')))[0])
            print 'Received', value,
            time.sleep(1)
            print 'and_sending', value

            self.client_sock.sendall(struct.pack('>H', value))

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 9999))
sock.listen(0)
print 'Waiting_for_clients_...'

while True: # Serve forever.
    client = sock.accept()
    ClientHandler(client).start()

a761f27bd626be754202ab872d7077f34d591415
import socket
import struct
import time
import threading

value = 0

class ClientHandler(threading.Thread):

    def __init__(self, client):
        threading.Thread.__init__(self)
        self.client_sock, self.client_addr = client

    def run(self):

        global value

        while True:
            value = int(struct.unpack('>H', self.client_sock.recv(struct.calcsize('>H')))[0])
            print 'Received', value,
            time.sleep(1)
            print 'and_sending', value

            self.client_sock.sendall(struct.pack('>H', value))

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 9999))
sock.listen(0)
print 'Waiting_for_clients_...'

while True: # Serve forever.
    client = sock.accept()
    ClientHandler(client).start()
