Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Winsock Control and Dynamic Array

Posted on 2003-03-25
4
Medium Priority
?
204 Views
Last Modified: 2013-11-13
I am trying to develop an application that will send a dynamic array to the server to process the files. the app is client/server app and the server is listening on port 1007. i am using winsock control. the client downloads some files from the server and than it stores the file names in a dymanic array and than send the results to the server to move the files to the archive directory. i don't know how i can pass the results of dynamic array (arrayFiles()) to the server?
thanks
sk
0
Comment
Question by:skhan22
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:bukko
ID: 8206856

Convert the array to a delimited string first, e.g.:

strCSV = Join( a_strMyArray, "," )

Then, when it is at the server end, convert it back into an array as follows:

a_strMyArray() = Split( strCSV, "," )

Obviously, you should choose a delimiter which would not normally appear in any of your array elements, such as Chr(31)

Hope it helps,

bukko

0
 
LVL 8

Accepted Solution

by:
bukko earned 150 total points
ID: 8206869

In your case, this would be:

strFiles = Join( arrayFiles(), Chr(31) )
' then send string using winsock.

At the other end...

' get string using winsock, then:
arrayFiles() = Split( strFiles, Chr(31) )

Regards

bukko

0
 

Author Comment

by:skhan22
ID: 8206954
thanks for your quick reply. let me as you this. what if i have the loop below

*** Loop on client to store the file names into array*****

sFile = Dir$("c:\*.txt") 'Get first entry
 
Do Until Len(sFile) = 0 'Loop until we run out (sFile will be empty)
  If Not sFile = "." And Not sFile = ".." Then
    ReDim Preserve sArray(i)
    sArray(i) = sFile   'Display what we found
    i = i + 1
  End If

  sFile = Dir$ 'Get next entry.
 
Loop

*******************************************************

After the above loop is done on the client. i want to send the results of variable i and sarray to the server and than let the server perform the loop below to get the file name and store it in strFile variable.

*** Loop on server to find the file names *****

For i = 0 To UBound(sArray) 'Now we have all the files in an array, so..
strFile = sArray(i)
Next i

************************************************

Any help of this would be greatly appreciated.
sk
0
 

Author Comment

by:skhan22
ID: 8227050
Thanks bukko for your help. your answer above helped me out with solving my problem.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

577 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