#!/usr/bin/env python
# Author: Manoel Vilela

import socket
import threading

HOST = 'ryukinix.tk'
PORT = 5558

s = socket.socket()
s.connect((HOST, PORT))
read_stream = s.makefile()
write_stream = s.makefile(mode='w')


def get_user_input():
    inp = input()
    print("\033[1A\033[2K", end='')
    return inp


def server_reader():
    """Fetch lines from server and print"""
    while not read_stream.closed:
        print(read_stream.readline(), end='')


def send_message(message):
    write_stream.write(message + '\n')
    write_stream.flush()


def main():
    try:
        username = input(str(read_stream.readline().strip('\n')))
        print("Connected as {}@{}:{}".format(username, HOST, PORT))
        send_message(username)
        inp = ""
        t = threading.Thread(target=server_reader)
        t.start()
        while inp != "/quit":
            inp = get_user_input()
            send_message(inp)
    except KeyboardInterrupt:
        send_message("/quit")
    finally:
        read_stream.close()
        write_stream.close()
        s.close()
        t.join()


if __name__ == '__main__':
    main()

@@ -70,16 +70,32 @@
 hreading
+%0Aimport readline
 %0A%0AHOST =
@@ -122,16 +122,92 @@
 = 5558%0A%0A
+# set editing-mode on input%0Areadline.parse_and_bind('set editing-mode vi')%0A%0A
 s = sock
@@ -465,16 +465,29 @@
 rint%22%22%22%0A
+    try:%0A    
     whil
@@ -516,24 +516,28 @@
 ed:%0A        
+   
+ 
 print(read_s
@@ -562,16 +562,253 @@
 end='')%0A
+    except ValueError:%0A        pass%0A        # after the read_stream is closed, in the case%0A        # the thread is running read_stream.readline()%0A        # is running this will throw a exception of%0A        # IO operation on closed file.%0A
 %0A%0Adef se

Add to client.py readline support and fix exit exception