Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help me to solve this winsock problem.

Posted on 2002-06-20
5
Medium Priority
?
195 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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…
Suggested Courses

927 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