• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • 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

thanx
0
wormboy__6
Asked:
wormboy__6
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?
0
 
JohnnCommented:
They all cost money, big money...think about though, what's your time worth...just find one and buy it...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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?
0
 
JohnnCommented:
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
 
anzenCommented:
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
 
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..

thanks
0
 
JohnnCommented:
email address?
0
 
wormboy__6Author Commented:
wormboy__666@hotmail.com
0
 
Shyam121498Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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