[Tutor] Why does this kill PythonWin IDE?
Patrick Kirk
patrick@kirks.net
Thu Jun 19 17:00:03 2003
This is a multi-part message in MIME format.
--------------050809080405070600080700
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Running this script in PythonWin IDE cause a hung app. Could anyone run
thsi for me as a test? I just need to check if i'st the script or have
I a problem with PythonWin IDE
--
Best regards,
Patrick Kirk
Mobile: 07876 560 646
--------------050809080405070600080700
Content-Type: text/plain;
name="server.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="server.py"
#! /usr/bin/env python
from re import * # get regex stuff
from socket import * # get socket stuff
myHost = '' # localhost
myPort = 6346 # free port
# Create listener and process input
def createSocket():
sockobj = socket(AF_INET, SOCK_STREAM) # makes socket object
sockobj.bind((myHost, myPort)) # binds it to server and port
# if sockobj < 1:
# print "cannot open socket "
sockobj.listen(50) # listen allowing 50 connections
while 1: # listen 'til process killed
connection, address = sockobj.accept() # waiting for connection
data = connection.recv(1024) # read next line on client socket
handshake0 = 'GNUTELLA CONNECT'
handshakeRequest = data.find(handshake0)
request = 'GET '
fileRequest = data.find(request)
if fileRequest > -1:
logGETs = open("GETsLog.html", "a")
logGETs.write('\r\n')
logGETs.write("'Server connected by ', address")
logGETs.write('\n')
logGETs.write(data)
logGETs.close()
connection.send('GNUTELLA/0.6 503 Full\r\n') # Gently say I can't help.
connection.close() # Rude but how does one say NO?
elif handshakeRequest > -1:
connection.send('GNUTELLA/0.6 200 OK\r\n' ) # lets see what reply we get
if not data: break # send reply line to client
logHandshake = open("handshakeLog.html", "a")
logHandshake.write('\r\n')
logHandshake.write(data)
logHandshake.close()
connection.close()
else:
logOthers = open("othersLog.html", "a")
logOthers.write('\r\n')
logOthers.write(data)
logOthers.close()
connection.send('GNUTELLA/0.6 503 Full\r\n') # Gently say I can't help.
connection.close()
createSocket()
--------------050809080405070600080700--