#!/usr/bin/python

import sys
import socket

def server():
  print("Starting Server")
  s = socket.socket()
  host = socket.gethostname()
  port = 12345
  s.bind((host,port))
  s.listen(5)
  while True:
    c,addr = s.accept()
    print("Got connection from ", addr)
    c.send("THanks")
    c.close()


def client():
  print("Starting Client")
  s = socket.socket()
  host = socket.gethostname()
  port = 12345
  s.connect((host,port))
  print("I got it from server", s.recv(1024))
  s.close()

if len(sys.argv) > 3 :
  server()
else :
  client()


