Solved

Help me to solve this winsock problem.

Posted on 2002-06-20
5
186 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
  • 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now