# L-28 MCS 275 Wed 15 Mar 2017 : talk_client.py
"""
Illustration of sockets for swapping data
between two clients.  The corresponding server
is the script talk_host.py.
"""
from socket import socket as Socket
from socket import AF_INET, SOCK_STREAM

HOSTNAME = 'localhost'  # on same host
PORTNUMBER = 11267      # same port number
BUFFER = 80             # size of the buffer

SERVER_ADDRESS = (HOSTNAME, PORTNUMBER)
CLIENT = Socket(AF_INET, SOCK_STREAM)
CLIENT.connect(SERVER_ADDRESS)

print('client is connected')
ALPHA = input('Give message : ')
CLIENT.send(ALPHA.encode())

print('client waits for reply')
BETA = CLIENT.recv(BUFFER).decode()
print('client received \"' + BETA + '\"')

CLIENT.close()
