473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sniffing at two sockets

In a simple VB script I open ADODB.Connection and start sending
some very simple T-SQL commands to a MS SQL Server. Like this:

------------------------------------------------------------

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

cn.Execute _
"select 'XXXXXXXXXXXX';" & _
"waitfor delay '00:00:03'; raiserror ('AAA',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('BBB',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('CCC',10,1) with nowait;" & _
"waitfor delay '00:00:03'; select 'YYYYYYYYYYYY';"

------------------------------------------------------------
BUT I do it (sending to\fro data) via two sockets opened in a python
code. Note: in above connection string I direct VB script to port 1434,
BUT the SQL Server listens to its default port = 1433.
Here my python code:
------------------------------------------------------------

import socket
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()
while 1:
data = cn.recv(4096)
if not data: break
s2.send(data)
print 'VB_SCRIPT:', data
data = s2.recv(4096)
if not data: break
cn.send(data)
print 'SQL_SERVER:', data
cn.close()
s1.close()
s2.close()

------------------------------------------------------------
And in the 0-approximation everything works just fine! I can
see printed intercepted requests\replies from VBS\SQLServer.
BUT alas it does not work EXACTLY as it works if the VB script
"connects" DIRECTLY to the "true" SQL Server's port = 1433.

After receiving the first error_message 'AAA' the VBS should
immediately issue something like 'Ready to receive next packet'
(in my newbish understanding), BUT instead it gets frozen till
its CommandTimeout times out and only then it wakes up, issues
a final request and gets ALL data that SQL Server "accumulated"
for the client's side; namely, error_messages 'BBB' and 'CCC'
and result of "select 'YYYYYYYYYYYY'".

ANY IDEAS WHY IT WORKS NOT QUITE CORRECTLY WILL BE GREATLY
APPRECIATED!!!

Jul 19 '05 #1
0 1804

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tero Saarni | last post by:
Hi, I have several threads communicating with each other using events stored in Queues. Threads block on Queue.get() until somebody publishes an event in thread's event queue. I need to add...
11
by: James | last post by:
I wasn't sure where to post this so I'm sorry if this is the wrong place. But I would like to know what some of the differences are between client-side and server-side browser sniffing. I'm aware...
4
by: BadOmen | last post by:
Hi, What is the different between 'System.Net.Sockets.Socket' and 'System.Net.Sockets.TcpClient'? When do I use System.Net.Sockets.TcpClient and System.Net.Sockets.Socket?? Yours, Jonas
3
by: Michael Maercker | last post by:
hi! i'm really not into networking at all and have now been asigned the task of porting a vb6-code into vb.net (compact framework, in this case) and the code uses the winsock-control. i quickly...
3
by: J C | last post by:
Hi, I'm using UDPClient to make a simple DNS server. I notice that intermittently and unpredictibly I get: Unhandled Exception: System.Net.Sockets.SocketException: An existing connection...
16
by: petermichaux | last post by:
Hi, Does anyone have a a cross-browser setOpacity function that does not use browser sniffing? I looked at the Yahoo! UI function and it detects IE by looking for window.ActiveXObject. I also...
1
by: RobG | last post by:
Browser sniffing is generally considered a very bad idea, developers are usually told that feature detection is the way to go. It seems a real pitty then that the developers of new platforms are...
1
by: Ken Fine | last post by:
I have been investigating programmatically downloading FLV content from various sites ("video scraping"??) Many interactive GUI tools do this, such as the Orbit downloader. At the heart of them...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.