Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WINSOCK senddata query

Posted on 2007-11-22
2
Medium Priority
?
929 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 240 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

671 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