Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2003, 09:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default TCP/IP Data is Being Concatenated

I am writing software in a client/server environment and I am wanting to communicate with the server and all the other clients using TCP/IP via the VB Winsock control.

I have an app running (written by me in VB) on the server which accepts TCP/IP connections and data from several clients (also written in VB). The clients also accept data from the server (of course :)).

The problem is that most of the time it works without any problems. But sometimes 2 messages will be sent by the server in quick succession, and again usually this works fine and the client receives 2 distinct DataArrival events. Then every so often the 2 messages will be concatenated (not by my app, but by the OS I think) and the client only receives 1 DataArrival event with the data being both messages concatenated.

The only way to stop it doing this after the first time it happens is to restart the server (as in restart Win2K, not just my app). I have gone through my code and can not find anything wrong with it. I do a DoEvents before and after every Winsock.SendData but still the concatenation happens...sometimes.

I think that it only happens when I have more than one client connected to my server app, but I can not guarantee that.

Has anyone else experienced this type of problem, and if so were you able to fix it and how?

I know I could change the way it works and look for an end of message flag and split it at the client, but I would prefer not change my code that much.

Regards
Owain Williams
__________________
Regards
Owain Williams
 
Old December 8th, 2003, 10:07 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

NOt going to help much, but a similar thing happens sometimes when using MSCOMM with RS232. The only way I have found to ensure that all is ok, is to test for string length's and data types coming in., part of the problem can be to do with noise on the line.

 
Old December 9th, 2003, 08:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As far as I know, winsock sends an event when there is data in the buffer, and then you can use the BytesReceived property to check how much data there is. I am not surprized if windows collapses events (and it is more efficient too)

Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
ZModem over TCP/IP geogomez Pro VB 6 4 December 27th, 2007 03:59 AM
another tcp/ip related query watashi C# 2005 0 August 30th, 2007 07:31 PM
Serial to tcp/ip watashi C# 2005 1 August 28th, 2007 01:48 AM
tcp\ip communication in asp.net 1.1 Pramods BOOK: Beginning ASP.NET 1.0 0 July 16th, 2007 03:51 AM
TCP/IP HELP jpsultana VB.NET 2002/2003 Basics 0 September 29th, 2005 01:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.