Solved

transferring files with winsock control

Posted on 1999-01-23
10
229 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
[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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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