|
-
Dec 7th, 2001, 04:02 PM
#1
Thread Starter
Addicted Member
Multiple File Transfers! HELPPPPP!
After the 30th million post, I am hoping outta the 24,000 members, at least one has the coding for multiple file transfers using winsock. This is gonna be my last post regarding the file transfering, cuz I'm officially sick of asking the questions and coming up with responses that members give simply to increase their post count. If you are gonna post a simple one sentance response, please don't. I am serious in looking for this bit of coding, and it seems as though every method you guys have givin me is laggy or too memory intensive. Now, anyone who knows how to perform a multiple winsock file transfer, please let me know (smash?). Thanks!
-
Dec 7th, 2001, 04:05 PM
#2
Fanatic Member
Easy Tiger
I`m supposta be the grumpy one.
-
Dec 7th, 2001, 04:14 PM
#3
PowerPoster
I am sorry that I don't have any code right now but, I was gonna say that I am developing a chat program that will, hopefully, support multiple files transfer. You can either wait or somebody else will able to write up some code for you. You can do that yourself too if you extend and follow this suggestion:
Whenever you are starting a new file transfer, you load a new winsock control out of an array, use that winsock to connect to the remote computer from wher you are getting the file, and then keep track of all those downloads by using some kind of array or a listbox/listview control.
-
Dec 7th, 2001, 04:21 PM
#4
Thread Starter
Addicted Member
Yeah, I've tried to before, but I kept failing at it cuz I just lost track of everything (too many things going at once). Anyway, the way I did it was too laggy for any machine, so I deleted it. I hope someone out there knows what they're doing, and a way to do it.
-
Dec 7th, 2001, 05:03 PM
#5
Hyperactive Member
-
Dec 7th, 2001, 06:31 PM
#6
Lively Member
Relax already, sheesh, we all can't sit here and read this board 24 - 7.
But since you asked so nicely, I am gonna show ya what you need. I have done multiple downloads through IRC, and this code works great for me. There are probably a couple of variables dimensioned that you do not need, so don't worry about them. The way I have it set up is I have a MDIChild form set up with a Winsock on it, and I just make a new instance of it everytime I want to download a new file. Set up a MDIChild form named whatever, mine's named DCCFileRecieved.
VB Code:
Public fileName As String
Public senderName As String
Public fileSize As String
Public I As Integer 'hold the file number of the opened file
Public totalSize As Double
Public goodFile As Boolean
Public lastTime As Long
Public Sub startNewSession(ip As String, port As String)
If WS.State <> sckClosed Then
WS.Close
End If
WS.Connect ip, port
T.Enabled = True
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
On Error GoTo err:
Dim strData As String
Dim size
WS.GetData strData, vbString
Print #I, strData;
size = LOF(I)
totalSize = totalSize + bytesTotal
lblRecieved.Caption = FormatNumber((totalSize / 1024), 2) & " K"
PB.Value = totalSize
If totalSize >= lblSize.Caption Then
Close #I
goodFile = True
WS.SendData lblSize.Caption
WS.Close
fileRecieveDone fileName, lblUserName.Caption
Unload Me
End If
err:
If err.Number <> 0 Then
If WS.State = 6 Then
Exit Sub
ElseIf err.Number = 11 Then
Resume Next
Else
Resume Next
End If
End If
End Sub
Public Sub openFile()
I = FreeFile
If Len(App.Path & "\Download\" & fileName) > 0 Then 'looks to see if file exists
Open App.Path & "\Download\" & fileName For Output As I
Close #I
End If
Open App.Path & "\Download\" & fileName For Output As I
End Sub
Private Sub T_Timer()
On Error Resume Next
DoEvents
Dim total As Double
total = (totalSize - lastTime)
lblSpeed.Caption = FormatNumber((total / 1024), 1) & " Kps"
lblTime.Caption = ((lblSize.Caption - totalSize) / total) * 60
lastTime = totalSize 'lastTime is the variable holding the size of the file the last
'time the timer was called
End Sub
Private Sub WS_Close()
If goodFile Then
Me.Caption = "File Recieved Successfully"
Else
Me.Caption = "Incomplete File"
End If
End Sub
On another form:
To download a file, use yourFormNameHere.startNewSession(ip, port)
In case of a water landing, my head may be used as a flotation device.
-
Dec 7th, 2001, 06:43 PM
#7
Thread Starter
Addicted Member
Thanks
It looks good, thanks. Anyone have the multiple sending part of it now?
Last edited by WAcKeD; Dec 7th, 2001 at 06:48 PM.
Thankz,
WAcKeD
-
Dec 7th, 2001, 06:50 PM
#8
Lively Member
No problem. But ya gotta remember to be patient. I posted several times on subjects similiar to this, and got little, if any response. So I then had to do everything for myself, which taught me so much more than someone handing me some code and saying here, this is exactly what you are looking for. Not tryin to sound like an ass, just want ya to relax. Life's too short to get your panties in a bunch. :-)
In case of a water landing, my head may be used as a flotation device.
-
Dec 7th, 2001, 10:00 PM
#9
Thread Starter
Addicted Member
I was thinking. Why not just make a class, then when someone wants to download, make a new one. What do you think?
-
Dec 8th, 2001, 10:33 AM
#10
Thread Starter
Addicted Member
Okay, the recieving code works, now all I need is something that will allow me to send the file multiple times. Does anyone know how this is done? You could create a cls maybe, and when someone wants to download, just create a new one and tell it to connect to the other persons computer. If you have an easier way, let me know. thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|