# Example 3: server3.py
# CSC249 Class Example
# J Cardell, Feb 2017

# You need to have two different processes on your
# computer to be able to have the client contact
# the server - at a different process number. 
# * Run the client *after* the server is running

# You could run the server from a terminal window
# and the client from Idle. Open the terminal,
# navigate to the correct folder with "cd" and run:
# $ python ./SocketsEx3_server.py

from socket import *
HOST = 'localhost'   # use the local host
PORT = 29876         # Assign a port number
ADDR = (HOST, PORT)  # Define a tuple for the address

# Create a  new socket object
serv = socket (AF_INET, SOCK_STREAM)

# Bind our socket to the address
serv.bind ((ADDR))  # uses the address tuple
serv.listen(5)      # will allow 5 connections
print ('listening...')

conn, addr = serv.accept()
print ('... connected!')
conn.send ('TEST')
conn.close()
