# L-28 MCS 275 Wed 15 Mar 2017 : remote_client.py
"""
Illustration of sockets in a client using TCP,
client and server are running on different machines.
The corresponding server is in remote_server.py.
"""

# nsloopup dezon.math.uic.edu
# Name:	dezon.math.uic.edu
# Address: 131.193.178.103

from socket import socket as Socket
from socket import AF_INET, SOCK_STREAM

SERVER = '131.193.178.103'  # IP address
PORTNUMBER = 41267          # port number
BUFFER = 80                 # buffer size

SERVER_ADDRESS = (SERVER, PORTNUMBER)
CLIENT = Socket(AF_INET, SOCK_STREAM)
try:
    CLIENT.connect(SERVER_ADDRESS)
    print('client is connected')
    DATA = input('Give message : ')
    CLIENT.send(DATA.encode())
except OSError:
    print('connection failed')

CLIENT.close()
