Solved

Help me to solve this winsock problem.

Posted on 2002-06-20
5
193 Views
Last Modified: 2013-11-13
I try to do a program for sharing file.  I need to send a list of file name (string) to remote pc.

file is a fileListBox
this is my loop to send data.

For c = 0 To file.ListCount
  winsockBrowse.SendData "<File>" & file.List(c)
  DoEvents
  msgbox "Pause"
Next c

The other side will received these data and add to a list box.

My problem is the data didn't add properly to list box.
something like this happen..
<File>c:\a.txt
<File>c:\b.txt<File>c.txt<File>d.txt......
<File>c:\z.txt

if i put a message box in the loop, then everything is ok.
How to solve this problem?
0
Comment
Question by:yongyih
[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
  • 2
5 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7095178
try 'sleep' instead of msgbox

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'and write this in place of msgbox
sleep(2000) 'sleeps for 2 sec

Hope this helps!

-priya
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7095186
how abt sending the fileListbox values in an "Array". This way you won't require a loop while sending data. Just send the array with values.

-priya
0
 
LVL 5

Accepted Solution

by:
Julian_K earned 50 total points
ID: 7095326
The problem is that you do not send any delimiters between the file names. So, when you send them one by one with a big pause between, they come in parts and that's ok, but if you skip your messagebox, they will fill the buffer and then be sent together as one string.
There are two simple approaches to your problem:
First is - add delimiters between the file names, while sending them one by one. Then on the reciever side, check for these delimiters (say chr(1) - this will never be found in a file name (: ) and split the string.

Second is - Add all filenames in a special-character delimited string. You can do this easily with the JOIN function that joins the elements of a varray into a delimited string.

Hope this helps.

Julian.
0
 
LVL 5

Expert Comment

by:Julian_K
ID: 7095335
To: priya_pbk
Sending directly an array... it may become too complicated, because the mscomm control maintains only binary and string. There will be conversions, that may lead to unwanted results. Pausing after each chunk of data is also not a good idea. This may take hours on a long list.
0
 
LVL 2

Author Comment

by:yongyih
ID: 7095749
Thank you for your help.
priya_pbk also can solve my problem but performance very slow.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

627 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