Solved

Winsock Connection

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
PHP question(s) about order of output 9 69
Exit a vb6 apps when a calling it apps closes 15 52
Hide vba in gp 7 106
Zip Folders Using Chilkat Routines 1 59
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

828 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