Code run from IDLE but not via double-clicking on its *.py

n00m n00m at narod.ru
Wed Aug 31 19:28:42 CEST 2005


Richie; Steve; Thanks for your replies!

>  o The command you're typing into the command prompt
>  o The error message you're getting
>  o The full traceback
>  o The code you're trying to run, or if it's too big then the piece that
>    the last line of the traceback refers to

1.
D:\>python23\python d:\python23\socket6.py [Enter]

It's OK so far. Python code is launched and starts listening
to port 1434 (see the code below; it's the same code as in my
neibouring topic).
Now I launch a vbs script (which will connect to port 1434).
I.e. I just double-click "my.vbs" file.
And... voila! In a moment & silently console window closes
without any error messages (or I just don't see them).
But VBS reports a network error. Tested on win2k and win98.


In IDLE it works ABSOLUTELY FINE! Prints statements in the
code do exactly what they must do.


import socket, thread
host, port = '127.0.0.1', 1434
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((host, 1433))
s1.bind((host, port))
s1.listen(1)
cn, addr = s1.accept()

def VB_SCRIPT():
    while 1:
        data = cn.recv(4096)
        if not data: return
        s2.send(data)
        print 'VB_SCRIPT:' + data + '\n\n'

def SQL_SERVER():
    while 1:
        data = s2.recv(4096)
        if not data: return
        cn.send(data)
        print 'SQL_SERVER:' + data + '\n\n'

thread.start_new_thread(VB_SCRIPT,())
thread.start_new_thread(SQL_SERVER,())




More information about the Python-list mailing list