Solved

Winsock Connection

Posted on 2002-03-26
2
176 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

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 …
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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…

762 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

19 Experts available now in Live!

Get 1:1 Help Now