@@ -0,0 +1,1529 @@
+#!/usr/bin/python%0A# -*- coding: utf-8 -*-%0A%0APORT = 50007%0A%0A# Echo server program%0Aimport socket%0Aimport sys%0Aimport json%0A%0AHOST = None               # Symbolic name meaning all available interfaces%0A%0A%0Adef bindto(host, port):%0A    s = None%0A%0A    for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):%0A        af, socktype, proto, canonname, sa = res%0A        try:%0A            s = socket.socket(af, socktype, proto)%0A        except socket.error as msg:%0A            s = None%0A            continue%0A        try:%0A            s.bind(sa)%0A            s.listen(1)%0A        except socket.error as msg:%0A            s.close()%0A            s = None%0A            continue%0A        break%0A%0A    if s is None:%0A        print 'could not open socket'%0A        return False, False%0A%0A    conn, addr = s.accept()%0A    return conn, addr%0A%0A%0Adef listen(so):%0A    left = ''%0A    while 1:%0A        data, left = recieve(so, left)%0A        if not data:%0A            break%0A        send(so, data)%0A%0A%0Adef recieve(so, before=''):%0A    msg = before%0A    while '%5Cr%5Cn' * 2 not in msg:%0A        msg += so.recv(1024)%0A    index = msg.find('%5Cr%5Cn' * 2)%0A    m = json.loads(msg%5B:index%5D)%0A    l = msg%5Bindex + 2:%5D if msg%5Bindex + 2:%5D != '%5Cr%5Cn' else %22%22%0A    return m, l%0A%0A%0Adef send(so, j):%0A    so.send(json.dumps(j) + '%5Cn%5Cn')%0A%0Aif __name__ == '__main__':%0A    so, ip = bindto(HOST, PORT)%0A    if not so:%0A        so, ip = bindto(HOST, PORT + 1)%0A        print PORT + 1%0A    print 'Connected by', ip%0A    send(so, %7B'hostname': 'ulb.ac.be'%7D)%0A    listen(so)%0A    so.close()%0A

Add a dummy python socket server