Sockets: code works locally but fails over LAN



import socket, thread
host, port = '192.168.0.3', 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,())

=============================================

The above code acts as an intermediator between a very simple VB script
and SQL Server. Like follows:
the vbs sends its requests to "fake" port 1434 and the python code
catches and re-sends them to sql server which listens to its DEFAULT
port = 1433... And vice versa.


=========================================================
VB script:
=========================================================

Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=192.168.0.3,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"

cn.Execute "select * from authors;"
cn.Close
Set cn = Nothing

=========================================================


It works fine (I see all client/server data printed in IDLE window)but
only locally. I.e. if vbs, python and sql server run on the same
machine.

If I run the vbs from some other machine in my LAN then it fails to
work out properly. Below is all that vbs and sql server are able to say
to each other:


===========================================================

VB_SCRIPT:
   SERVER qwe asdasd 000000a5 Р·€Ut
 Microsoft (r) W 192.168.0.3,1434  asdasd
 OLEDB 


SQL_SERVER:
 Щ 3 г
pubsmaster«0 E  # Changed database context
to 'pubs'.W г

us_english «4 G  ' Changed language setting to us_english.W г
cp1251 ­  Microsoft SQL Server _ Вг 40964096э


VB_SCRIPT:
 G   4096 

==========================================================


In abt 30 seconds OLE DB Provider (on the vbs side) reports "General
Network Error".


PEOPLE, WHY ON THE EARTH IT DOES NOT WORK OVER LAN ???

PS:
Of course, without involving Python into the process vbs and sql server
communicate with each other just fine - no matter locally or over LAN;
on win2k machines or on/from NT 4.0 machine.

.



Relevant Pages

  • Re: ADP problems after SQL 2005 Upgrade
    ... Use the SQL Server Configuration Manager to create aliases; ... each port can be associated only with a single instance. ... Sylvain Lafontaine, ing. ...
    (microsoft.public.access.adp.sqlserver)
  • [NT] Microsoft SQL Server 2000 Unauthenticated System Compromise
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... Microsoft's database server SQL Server 2000 exhibits two buffer-overrun ... clients connecting to TCP port 1433 or both. ... This message is a single byte packet, ...
    (Securiteam)
  • Re: Do SqlServer 2000 & SqlServer 2005 co-exist
    ... Either SQL Server 2000 or SQL Server 2005. ... So you have to move one of them to another port. ... You could allow an program exception in your firewall instead of a port number exception. ... I understand that you can connect to SQL 2000 named instance on the local ...
    (microsoft.public.sqlserver.setup)
  • Re: IIS, SQL 2000 & XPs Firewall
    ... Only one instance of SQL Server can use TCP port 1434. ... You may find it easier to use SQL Server Configuration Manager ... 2008 will be a named instance ... you will have to open those as exceptions in the firewall. ...
    (microsoft.public.sqlserver.connect)
  • Re: SQL 200 Dev edition on workgroup will not connect
    ... I have been using sql server for about 8 years but mainly working with sql 2000. ... know your experience level with SQL Server and yes, sometimes things being messy but letting a SQL Server instance to accept remote connections and uninstalling it are generally straightforward tasks to perform. ... I suggest you to check for the dynamic port number that your SQL Server graps. ... Write down the port number in the "TCP Dynamic Ports" property and then run a Command Prompt and see if this port is bening listened. ...
    (microsoft.public.sqlserver.connect)