[PYTHONMAC-SIG] daemons on the Mac
Anthony M. Ingraldi
A.M.INGRALDI@larc.nasa.gov
Fri, 29 Aug 1997 16:36:58 -0400
>Shouldn't that be listen(1)? I use socket stuff on the Mac "all the
>time" and it's all working for me... but on some systems listen(0)
>really doesn't work...
>
I changed the listen(0) to listen(1) and the server works. However, if I
bring the server application to the front I have to force quit it or my Mac
is stuck racing around the 'while 1' loop. Can a python app be made into a
faceless background app? Alternatively, is there a way to allow user
interaction in the 'while 1' loop?
Here's the code again...
from socket import *
PORT = 79 # the finger port
BUFSIZE = 1024
def main():
s = socket(AF_INET, SOCK_STREAM)
s.bind('', PORT)
s.listen(1)
while 1:
conn, (remotehost, remoteport) = s.accept()
data = conn.recv(BUFSIZE)
# do something with data
conn.send("done")
conn.close()
del conn
main()
--
Tony Ingraldi | e-mail: A.M.INGRALDI@LaRC.NASA.GOV
NASA Langley Research Center |
Mail Stop 267 | Phone : (757) 864-3039
Hampton, VA 23681-0001 | Fax : (757) 864-7892
_______________
PYTHONMAC-SIG - SIG on Python for the Apple Macintosh
send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
_______________