#!/usr/bin/env python

import socket, select, string, sys


def ParseMessage(msg):
	# Edit for your purpose
	
	# We print the msg for this tutorial
	sys.stdout.write(msg)


def RequestMessage() :
	sys.stdout.write('<You> ')
	sys.stdout.flush()

if __name__ == "__main__":
	
	# Enter the server's IP and Port
	host = 'x.x.x.x'
	port = 5000

	# Boolean to keep the client running
	runClient = True

	# Create socket instance
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.settimeout(2)
	
	# Attempt to connect to server
	try :
		s.connect((host, port))
	except :
		print('Unable to connect')
		sys.exit()
	
	print('Successfully connected to remote host.')
	RequestMessage()
	
	while runClient:

		# Moniter the user's input and the server
		socket_list = [sys.stdin, s]
		
		# Obtain list of readable sockets
		read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
		
		for sock in read_sockets:

			# New messages from server
			if sock == s:
	
				# Recieve message
				data = sock.recv(4096).decode()
	
				if not data :
					print('\nDisconnected from chat server')
					sys.exit()
	
				else :
					# Parse valid message
					sys.stdout.write(data)
					# ParseMessage(data.decode())
					RequestMessage()
			
			# Recieve message from user
			else :
				msg = sys.stdin.readline()
				s.send(msg.encode())
				RequestMessage()

	s.close()
cb172236fec515920c0908b69af9eaf8e28e89e5
<mask token>


def RequestMessage():
    sys.stdout.write('<You> ')
    sys.stdout.flush()


<mask token>

<mask token>


def ParseMessage(msg):
    sys.stdout.write(msg)


def RequestMessage():
    sys.stdout.write('<You> ')
    sys.stdout.flush()


<mask token>

<mask token>


def ParseMessage(msg):
    sys.stdout.write(msg)


def RequestMessage():
    sys.stdout.write('<You> ')
    sys.stdout.flush()


if __name__ == '__main__':
    host = 'x.x.x.x'
    port = 5000
    runClient = True
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(2)
    try:
        s.connect((host, port))
    except:
        print('Unable to connect')
        sys.exit()
    print('Successfully connected to remote host.')
    RequestMessage()
    while runClient:
        socket_list = [sys.stdin, s]
        read_sockets, write_sockets, error_sockets = select.select(socket_list,
            [], [])
        for sock in read_sockets:
            if sock == s:
                data = sock.recv(4096).decode()
                if not data:
                    print('\nDisconnected from chat server')
                    sys.exit()
                else:
                    sys.stdout.write(data)
                    RequestMessage()
            else:
                msg = sys.stdin.readline()
                s.send(msg.encode())
                RequestMessage()
    s.close()

import socket, select, string, sys


def ParseMessage(msg):
    sys.stdout.write(msg)


def RequestMessage():
    sys.stdout.write('<You> ')
    sys.stdout.flush()


if __name__ == '__main__':
    host = 'x.x.x.x'
    port = 5000
    runClient = True
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(2)
    try:
        s.connect((host, port))
    except:
        print('Unable to connect')
        sys.exit()
    print('Successfully connected to remote host.')
    RequestMessage()
    while runClient:
        socket_list = [sys.stdin, s]
        read_sockets, write_sockets, error_sockets = select.select(socket_list,
            [], [])
        for sock in read_sockets:
            if sock == s:
                data = sock.recv(4096).decode()
                if not data:
                    print('\nDisconnected from chat server')
                    sys.exit()
                else:
                    sys.stdout.write(data)
                    RequestMessage()
            else:
                msg = sys.stdin.readline()
                s.send(msg.encode())
                RequestMessage()
    s.close()

#!/usr/bin/env python

import socket, select, string, sys


def ParseMessage(msg):
	# Edit for your purpose
	
	# We print the msg for this tutorial
	sys.stdout.write(msg)


def RequestMessage() :
	sys.stdout.write('<You> ')
	sys.stdout.flush()

if __name__ == "__main__":
	
	# Enter the server's IP and Port
	host = 'x.x.x.x'
	port = 5000

	# Boolean to keep the client running
	runClient = True

	# Create socket instance
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.settimeout(2)
	
	# Attempt to connect to server
	try :
		s.connect((host, port))
	except :
		print('Unable to connect')
		sys.exit()
	
	print('Successfully connected to remote host.')
	RequestMessage()
	
	while runClient:

		# Moniter the user's input and the server
		socket_list = [sys.stdin, s]
		
		# Obtain list of readable sockets
		read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
		
		for sock in read_sockets:

			# New messages from server
			if sock == s:
	
				# Recieve message
				data = sock.recv(4096).decode()
	
				if not data :
					print('\nDisconnected from chat server')
					sys.exit()
	
				else :
					# Parse valid message
					sys.stdout.write(data)
					# ParseMessage(data.decode())
					RequestMessage()
			
			# Recieve message from user
			else :
				msg = sys.stdin.readline()
				s.send(msg.encode())
				RequestMessage()

	s.close()