Exemple #1
0
def handle_client_send(sock, q, addr):
    #send updated que to the client
    while True:
        msg = q.get()
        if msg == None: break
        try:
            chatmsg.send_msg(sock, msg)
        except (ConnectionError, BrokenPipe):
            handle_disconnect(sock, addr)
            break
Exemple #2
0
def handle_input(sock):
    #Send the input msg to server
    print("Type message ; enter to send ; 'q' to quit")
    while True:
        msg = input()
        if msg == 'q':
            sock.shutdown(socket.SHUT_RDWR)
            sock.close()
            break
        try:
            chatmsg.send_msg(sock,msg)
        except (BrokenPipeError, ConnectionError):
            print('socket error')
            break