Solved

Help me to solve this winsock problem.

Posted on 2002-06-20
5
192 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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