Solved

transferring files with winsock control

Posted on 1999-01-23
10
218 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now