Solved

Winsock Connection

Posted on 2002-03-26
2
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

628 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