[PythonCE] Server socket + MessageBox hangs ?
Olivier Fambon
Olivier.Fambon@xrce.xerox.com
Thu, 28 Nov 2002 11:28:13 +0100
Telion [Wed, 27 Nov 2002 08:54:43 -0800 (PST)] wrote:
>
> By adding above two lines,
Yes, sorry for the bad copy/paste.
> this script worked fine on my machine. (PythonCE2.2+ on HPC2000)
Mine is an iPaq 3660, CE3.0 (fr), PythonCE2.2+ (cab)
> I connected with Teraterm telnet software, disconnected,
> and reconnected without problem.
I use a unix telnet, but I guess it should not cause a hang. I also
tried with an NT telnet.
The thing is not that I am not able to connect - at socket level- a
second time... Actually, it _does_ connect, but it hangs - in
accept(): there is no message [print], no message box, and from there
on I can not connect a 3rd time.
> Maybe you should check if you are not trying to run
> 2nd copy of Python while the server is still active
> (but not visible due to the PPC interface).
No other Python running (I reboot on every test :).
This even-simpler script shows the same behaviour: no message box on
the second connection, and kills the Q-menu.
# Blocks on accept() on second connection on iPaq 3660 CE3.0 PyCE2.2+
# Commenting out the win32gui.MessageBox cures the hanging
import socket, win32gui
def doServer(host='', port=2000):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(1)
while 1:
print 'waiting for connection on ', port
conn, addr = s.accept()
print 'Connected by', addr[0]
win32gui.MessageBox(0, "Lo", "Title", 1)
conn.close()
doServer()