Solved

Winsock Connection

Posted on 2002-03-26
2
179 Views
Last Modified: 2013-11-13
Dear All,

I have two application that using winsock control which is a server and client.

My client program is connect to server that to transfer  text file from server to client.

My problem:
In server i have store all the text file in one folder, and my client program only can tansfer one file at a time. in this situation how my client program can make a one connection and transfer all the file inside the folder to the client side?  
Example : Loop until all the file inside folder have been transfer to the client and will close the connection.

It is possible the winsock can transfer more than one file at a time (i mean is one after another)?

Any help is appreciate .


Thanks in advance.







0
Comment
Question by:seem
  • 2
2 Comments
 
LVL 8

Accepted Solution

by:
glass_cookie earned 100 total points
ID: 6895881
Hi!

I asumen that you do know how to use the winsock control.

To do that, you could do something like:

Load the list of filepaths into a listbox, or use a filelistbox control and set it's path to that of your desired folder.

Then, do some coding like this:
'At the declarations area, declare this booleam variable
'This variable is used to determine if the entire file is sent
Dim SentFinished as Boolean

For i = 0 To List1.ListCount - 1
SentFinished = False
'Coding for opening the text file to a string called MyFile
'Send the filename over
Winsock.SendData "File: " & List1.List(i)
Send the file details
Winsock.SendData MyFile

While SentFinished = False
DoEvents
Wend
Next i

Then, in your winsock control's SendCOmplete event, add this line of code:

SentFinished = True

That's it!

glass cookie : )

PS. Let me know where I'm not clear : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6895890
Arrrgh!  Spotted an eror.  The main looping code should be changed to this:


For i = 0 To List1.ListCount - 1
'Coding for opening the text file to a string called MyFile
'Send the filename over
Winsock.SendData "File: " & List1.List(i)
Send the file details
SentFinished = False
Winsock.SendData MyFile

While SentFinished = False
DoEvents
Wend
Next i

Ofcourse, your client program at the other side should keep checking for the string "File: " to determine that it's the file data, not the filepath of a file so as not to corrupt the text file and to have a location to save the file : )

That's it!

glass cookie : )
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

18 Experts available now in Live!

Get 1:1 Help Now