Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6
Winsock and SendData - VB6 Winsock and SendData - VB6
Winsock and SendData - VB6
Go Back  Xtreme Visual Basic Talk > > > Winsock and SendData - VB6


Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2011, 07:03 AM
whitejava whitejava is offline
Newcomer
 
Join Date: Nov 2011
Posts: 2
Question Winsock and SendData - VB6


Question is: How can I send two strings using SendData in different packets?

Because when I send two strings one after another, winsock joins them in a single packet thus making one string received from client/server. For example:

Code:
Winsock1.SendData "String1"
Winsock1.SendData "String2"
The final received data will be: "String1String2"
I guess winsock joins data that are sent in short period of time, is there any way to avoid this?

If the packets are analyzed by any sniffer software, there will be one packet containing both strings. Is there any way I can send these two strings separately, in different packets of TCP?

Thank you in advance.
#WJ
Reply With Quote
  #2  
Old 11-09-2011, 07:29 AM
PlausiblyDamp's Avatar
PlausiblyDampWinsock and SendData - VB6 PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Is there a reason you need these to go as two packets rather than as a single packet? Wouldn't it be easier to just send a delimiter between the two strings and let the server split based on this?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 11-09-2011, 03:59 PM
whitejava whitejava is offline
Newcomer
 
Join Date: Nov 2011
Posts: 2
Default

Yes it would be easier if there are really just two strings, but that's just an example I provided. Actually my project it's quite more complicated, there are 3 list boxes, each listbox should have specific strings listed and amount of strings can go up to hundreds.

So if I would know just how to send them separately every problem will be solved.

I appreciate your suggestion.
Reply With Quote
  #4  
Old 11-10-2011, 03:12 AM
mkaras's Avatar
mkarasWinsock and SendData - VB6 mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

You need to stop thinking of trying to use the underlying protocol to split or delimit your data. As PlausiblyDamp has already suggested you should put everything you need to comprehend your data partitioning right into the actual data that you send. This way the receiving end can understand just how to unpack the data according to your specifications.

If you indeed have 100's of strings in each grouping and if you try to send them thinking that the underlying protocol should group them for you - then what happens when the data length surpasses the size of the "packets" in that underlying protocol? // By the way - the wisdom of using list boxes with 100's of items is something you may want to think about - but that is a subject for another discussion. //

When you do it as suggested you can then achieve a data flow process that will work fitted to your application exactly. Another benefit is that you can end up making the data flow process in a way that is agnostic to the actual path that your data took in its way from the transmitter to the receiver. It could be over TCP/IP using Winsock but could have worked equally well flowing over some other serial connection!!

When you devise the partitioning scheme that you lay into the data it can be a good idea to introduce something that may be extensible for future usage. So instead of simply just putting say a <cr> delimiter after each string sent you may want to add some other information as well into a "header" that you send with each item or group of items. This header could include things such as:
- data item count...
- data type tag...
- data routing indicator...
- data block sanity checking codes...
- and whatever else that you would care to invent............

Michael Karas
Reply With Quote
  #5  
Old 11-10-2011, 10:01 AM
dilettante's Avatar
dilettanteWinsock and SendData - VB6 dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,529
Default

And that aspect of it isn't much different from the considerations involved in developing a disk file format.
Reply With Quote
  #6  
Old 11-10-2011, 10:33 AM
passel's Avatar
passelWinsock and SendData - VB6 passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

You should also realize that you are using TCP, by the sounds of it, which is a "streaming" protocol. So the "packets" will vary in size depending on the speed at which you "stream" the data. TCP will buffer and combine the stream of bytes into larger packets for efficiency. Since it is a stream of bytes, TCP won't care if it splits one of your strings between two packets but if a packet is lost, TCP will be buffering the packets while it asks for the missing packet to be retransmitted.
I think there is an option where you can force the TCP packet to be transmitted immediately, rather than be aggragated, but having information in the stream to allow processing as already mentioned is the normal way to go when using TCP.

If you wanted to send data packets, not a data stream, then another protocol, such as UDP could be used. But then, while each call to SendData would generate a datagram packet for that one call (and possibly extra extenstion packets if the data wouldn't fit in a single packet), ensuring that you didn't lose one of those packets would be up to your application, not built into the protocol.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply

Tags
packets, senddata, separate, vb6, winsock


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6 Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6 Winsock and SendData - VB6
Winsock and SendData - VB6
Winsock and SendData - VB6
 
Winsock and SendData - VB6
Winsock and SendData - VB6
 
-->