Solved

transferring files with winsock control

Posted on 1999-01-23
10
221 Views
Last Modified: 2013-12-26
Can someone please xplain to me how to transfer a file using the winsock control in vb5.
I understand how to do it i just dont know how to put it into vb code.

Please include exaples of code that i would need to use and if there is a winsock transferrring files control somewhere can someone please tell me where to get it

thanx
0
Comment
Question by:wormboy__6
10 Comments
 
LVL 1

Accepted Solution

by:
Johnn earned 10 total points
ID: 1489901
0
 

Author Comment

by:wormboy__6
ID: 1489902
this is only a trial control and has that very annoying about screen...do u know of any other controls that i can get which do the same things?
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1489903
They all cost money, big money...think about though, what's your time worth...just find one and buy it...
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:wormboy__6
ID: 1489904
ok then..instead of using a control...how can i specify the winsock control to send chunks of text from a text box.....

eg. send the first 8k block...then the next then the next....
and also what is the biggest chunk of data the winsock control can send and recieve at one time?
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1489905
A.  I don't know how to tell what the buffer is set for.  That's probably set somewhere in the control panel.

B.  There's no guarantee with winsock that eack "chunk" will be received without previous/next chunks appended to it.  You can build some kind of header scheme in it but this takes work.  I don't even think most of the controls on the market today guarantee each "chunk" is received by it's self.  The control I know of that does is the one I refered you to and it's well worth it's small price tag.

C.   I'm not prepared to provide a substantial implemenation method but what I will give you is some sample code that you'll need to play with(just whatch out for GPF's).  Also, this sample works only when your receiver has the decipher code.

sending...
dim txtToSend as string
dim txtBlock() as byte
dim lenBlock as long
txttosend=text1.text
lenblock=len(txttosend)'
redim txtblock(0 to lenblock+4)
'the following line of code converts the lenblock into the first four bytes of this data
copymemory txtblock(0),lenblock,4
'the following line adds the text your sending to this byte array
copymemorystr txtblock(0),txttosend,lenblock
winsock1.senddata txtblock

receiving...(this gets a little more complicated)
static Receiving as boolean
static lenComing as long
static txtRec as string
dim myByte() as byte
if not receiving then
'check for the length that coming
winsock2.getdata myByte,vbarray+vbbyte,4
'decrease the bytesTotal parameter by 4
bytesTotal=bytesTotal-4
'now rebuild this 4 byte block to tell us how many bytes will be coming altogether
copymemory lencoming,myByte(0),4
if bytestotal>lencoming then
'we have more than we want so there must be more coming
elseif bytestotal<lencoming then
'we have less than we wanted so lets wait for more
else
'must be exactly
endif


Ahh forget it! I don't have time to do the work for you.  If you want to do it on your own(don't buy a control) then you can do it yourself.  I've given you plenty of code to start with...now you just need to figure out what I left out.

PS maybe for 500 points I'll show you exactly how to do it...
0
 
LVL 4

Expert Comment

by:anzen
ID: 1489906
I suggest You to take a look at the Catalyst socketwrench control at http://www.catalyst.com, it's FREE and powerful, this because the standard WinSock distributed with VB has some flaws and NO "IsWritable" property to tell You if the socket has enough buffer free to write other data, about the data transfer You'd better peek around and take a look at the RFC documents explaining the FTP protocol, it's not so hard to implement and should fit the bill

Bye

0
 

Author Comment

by:wormboy__6
ID: 1489907
ok then..ive decided that ill just use a ftp control to send and recieve files in my client and server programs

but can anyone please xplain to me how to set up a ftp server....what is a good control to set it up with and how do i do it....code examples would be greatly appreciated..

thanks
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1489908
email address?
0
 

Author Comment

by:wormboy__6
ID: 1489909
wormboy__666@hotmail.com
0
 
LVL 1

Expert Comment

by:Shyam121498
ID: 1489910
I don't think u have to use a different control, use this code.

Open App.Path & "filename" For Input As filenum
    Do While Not EOF(filenum)
      Line Input #filenum, tmpData
      strData = strData + vbCrLf + tmpData
    Loop

wnSckClnt.SendData strData
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Acccess - Update Field in Table when report is printed 6 44
Passing a Text Box name to a Sub 6 96
VB6 ListBox Question 4 44
VBA - If Bookmark = "XXBOOKMARKXX" then 15 28
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 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