Solved

Winsock Connection

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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 is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

777 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