Solved

WINSOCK senddata query

Posted on 2007-11-22
2
924 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
[X]
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
2 Comments
 
LVL 86

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Added a column screws up code 5 78
Problem to With line 4 87
checkbox to hide entire section 10 76
Visual Basic 6: Code needed for TripleDES Encryption/Decryption 14 95
This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

751 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