• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

transferring files with winsock control

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

1 Solution
wormboy__6Author Commented:
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?
They all cost money, big money...think about though, what's your time worth...just find one and buy it...
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

wormboy__6Author Commented:
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?
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.

dim txtToSend as string
dim txtBlock() as byte
dim lenBlock as long
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
'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
'must be exactly

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...
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


wormboy__6Author Commented:
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..

email address?
wormboy__6Author Commented:
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

wnSckClnt.SendData strData
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now