(no subject)

Jack Jansen (Jack.Jansen@cwi.nl)
Mon, 23 Mar 1992 10:09:30 +0100

That's fairly simple. The reason for having separate 'listen' and
'accept' calls in the bsd socket stuff is to do exactly that. Here's
the fixed code:

#this is a finger program I am writing in the python language
#it isn't working so hot.....
#

import string
from time import sleep
import sys
from socket import *
from pwd import getpwnam

PORT = 45678
SIZE = 10

def main(): #recognize this?
if len(sys.argv) > 1:
PORT = int(eval(sys.argv[1]))
else:
PORT = 45678
s = socket(AF_INET, SOCK_STREAM)
s.bind('', PORT)
s.listen(3)
while 1:
conn, (remotehost, remoteport) = s.accept()
print 'Connection from ', remotehost, ' established.'
data = conn.recv(SIZE)
print len(data)
data = data[:-2]
field = getpwnam(data)
for x in range(len(field)):
conn.send(string.zfill(field[x], 1))
conn.send('\n')
conn.send('\n')
conn.close()

main()

--
Jack Jansen        | If I can't dance I don't want to be part of
Jack.Jansen@cwi.nl | your revolution             -- Emma Goldman
uunet!cwi.nl!jack    G=Jack;S=Jansen;O=cwi;PRMD=surf;ADMD=400net;C=nl