Re: Sockets: code works locally but fails over LAN
- From: "n00m" <n00m@xxxxxxxx>
- Date: 3 Sep 2005 16:43:06 -0700
Bryan;
Look at how I corrected your the very first version
(see added arguments in both functions). And now it
really can handle multiple connections!
import socket, thread
sqls_host, sqls_port = '127.0.0.1', 1433
proxy_host, proxy_port = '127.0.0.1', 1434
# How I tested it:
# sqls_host, sqls_port = 'www.google.com', 80
def VB_SCRIPT(s2, cn):
while 1:
data = cn.recv(4096)
if not data: return
s2.sendall(data)
print 'VB_SCRIPT:' + data + '\n'
def SQL_SERVER(s2, cn):
while 1:
data = s2.recv(4096)
if not data: return
cn.sendall(data)
print 'SQL_SERVER:' + data + '\n'
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind((proxy_host, proxy_port))
s1.listen(5)
while 1:
cn, addr = s1.accept()
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((sqls_host, sqls_port))
thread.start_new_thread(VB_SCRIPT,(s2, cn))
thread.start_new_thread(SQL_SERVER,(s2, cn))
Without these corrections I got these error messages
when I launched SIMULTANEOUSLY 3 instances of my.vbs:
Unhandled exception in thread started by
Unhandled exception in thread started by
Traceback (most recent call last):
Traceback (most recent call last):
File "D:\Python23\00\socket_Br10.py", line 18, in SQL_SERVER
File "D:\Python23\00\socket_Br10.py", line 13, in VB_SCRIPT
data = s2.recv(4096)
s2.sendall(data)
socket File "<string>", line 1, in sendall
..socketerror.: error: (10054, 'Connection reset by peer')
(10054, 'Connection reset by peer')
.
- Follow-Ups:
- Re: Sockets: code works locally but fails over LAN
- From: Bryan Olson
- Re: Sockets: code works locally but fails over LAN
- References:
- Re: Sockets: code works locally but fails over LAN
- From: John Hazen
- Re: Sockets: code works locally but fails over LAN
- From: n00m
- Re: Sockets: code works locally but fails over LAN
- From: Bryan Olson
- Re: Sockets: code works locally but fails over LAN
- From: Bryan Olson
- Re: Sockets: code works locally but fails over LAN
- From: n00m
- Re: Sockets: code works locally but fails over LAN
- From: n00m
- Re: Sockets: code works locally but fails over LAN
- From: Bryan Olson
- Re: Sockets: code works locally but fails over LAN
- From: Bryan Olson
- Re: Sockets: code works locally but fails over LAN
- Prev by Date: Language Work Benches in Py
- Next by Date: Re: descriptors for container items
- Previous by thread: Re: Sockets: code works locally but fails over LAN
- Next by thread: Re: Sockets: code works locally but fails over LAN
- Index(es):
Relevant Pages
|
|