#! /usr/local/bin/python
# -*- Mode: Python; tab-width: 4 -*-

import socket
import select

def feed (file, port=8053):
	fd = open (file, 'rb')
	s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
	s.connect (('', port))
	s.setblocking (0)
	i = 0
	while 1:
		r,w,e = select.select ([s],[s],[s])
		if r:
			print s.recv(1024)
		if w:
			l = fd.readline()
			if l:
				i = i + 1
				s.send (l[:-1]+'\r\n')
		if e:
			break

import sys
if __name__ == '__main__':
	feed (sys.argv[1])
