Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

WINSOCK senddata query

Posted on 2007-11-22
2
921 Views
Last Modified: 2013-12-20
Hi, Hopefully someone who reads this will know straight away...

I have a server app and a client app. The serverapp recieves data using a TCP stream, and then executes the said data as an SQL statement on a database. The clientapp sends the SQL strings in plain text to the serverapp. This works like a charm, providing you do one statement at a time.

This is the clientapp code that sends the SQL statement (there is 15 lines or so that manipulate the string 'mysqlstring' before sending but its irrelevant):

For y = 1 To x
winsock.senddata(mysqlstring)
Next

Complicated, huh? Heres the problem: if x is 1, everything is perfect. Serverapp gets the stream and executes it OK. But, if x is anything above 1, it sends all the 'mysqlstrings' in the same TCP packet - so when my serverapp recieves the data, it trys to execute all the strings in one command - like "SELECT * FROM PRODUCT_DETAILSSELECT*FROM CUSTOMER_DETAILS" - which (unsuprisingly) it doesn't like and bombs out.

I can't use any kind of timer because this is to be used for performance testing (i.e. how many queries can it do in 60 seconds) so a timer would defeat the whole point.
I'm not willing to change any of the serverapp code to use a deliminator to seperate queries in the same packet.

My guess is that the cause is VB itself - it does all the crap itself (like handling TCP/IP) and because the winsock.senddata function gets called in such quick succession (mere milliseconds) it thinks "OK, I'll just send them all in one go".

Is this a correct understanding and does anyone know how to make it send the data immediatley when the function is called?


TY
0
Comment
Question by:pinkisthenewblue
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 80 total points
ID: 20339419
The "stacking" of data may or may not occur within VB itself.  It may actually happen along the way at any of the points where the data stops and gets passed along.  You do NOT have any control over this.  Even if you forced the data to move out of your app seperately, it could still get bottlenecked somewhere else along the way and become one bigger packet before it reaches its destination.

You said it yourself...

    "The serverapp recieves data using a TCP stream"

TCP is a STREAM...and this type of behaviour is INHERENT in the way TCP packets are handled by servers.  The ONLY way to properly handle this problem is to add some kind of "end of message" marker (typically a simple delimiter) so you can distinguish where one message stops and another begins.

I think you already knew exactly what needs to be done!  =\
0
 
LVL 2

Author Comment

by:pinkisthenewblue
ID: 20343438
I didn't realise TCP packets can get merged into one big packet - so even if I did manage to get it to send the data as and when I specify it would be futile anyway.

Truthfully I didn't want to re-code my server app because its written in vb.net and I struggle to get the basics working! I will start re-coding it.

Thanks for your reply.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question