include tcp.repy

MSS = 2

if callfunc == 'initialize':
  IP = '127.0.0.1' #  getmyip()
  PORT = 12345
  PORT_TWO = 12346
  MESSAGE = "hi hows it going foo bar baz good bye??"
  MAXLEN = 1000000 # all of it

def server():
  socket = Connection()
  socket.bind(IP, PORT_TWO)
  socket.listen()
  tcup, addr = socket.accept()
  tcup.disconnect()

def client():
  socket = Connection()
  socket.way_to_close = THREE_WAY # send FIN-ACK
  socket.bind(IP, PORT)
  socket.connect(IP, PORT_TWO)
  sleep(1)
  socket.timeout = .1
  try:  
    bytes = socket.send(MESSAGE)
  except TimeoutError:
    pass
  else:
    raise Exception("should have timed out or something")

def main():
  settimer(0, server, ())
  sleep(.01)
  client()

if callfunc == 'initialize':
  main()
  exitall()
