-
Nov 20th, 2007, 08:20 PM
#1
Thread Starter
New Member
File Transfer Help
Im working on file transfer between client and server. This is the data arrival code on the server end:
vb Code:
Private Const chunk = 4096
Dim numfile As Integer
Private Sub Socket2_OnDataArrival(ByVal bytesTotal As Long)
Dim NData() As String
Dim data As String
Socket2.GetData data
NData = Split(data, "|")
Select Case NData(0)
Case "<GH>"
numfile = FreeFile
Open (Dir1.Path & "\" & NData(1)) For Binary As #numfile
filecont = Input(chunk, #numfile)
Socket2.SendData filecont
Case "<NP>"
If EOF(numfile) = True Then
Close #numfile
Socket2.SendData "<EF>"
Else
filecont = Input(chunk, #numfile)
Socket2.SendData filecont
End If
End Select
End Sub
'And here is the code for the data arrival on the client side:
Private Sub Socket2_OnDataArrival(ByVal bytesTotal As Long)
Dim NData() As String
Dim data As String
Socket2.GetData data
NData = Split(data, "|")
Select Case NData(0)
Case "<FD>"
Dim fname As String
fname = NData(1)
Const ATTR_DIRECTORY = 16
If Dir$(App.Path & "\" & "Downloads", ATTR_DIRECTORY) = "" Then
MkDir (App.Path & "\" & "Downloads")
End If
Open (App.Path & "\Downloads\" & fname) For Binary As #1
Socket2.SendData ("<GH>|") & NData(1)
Case "<EF>"
Close #1
Socket2.CloseSocket
Text1.Text = Text1.Text & vbCrLf & "File Downloaded"
Case Else
Put #1, , data
DoEvents
Socket2.SendData "<NP>"
End Select
End Sub
Where I am getting the error is on the server side. Locally when I run both the client and server and transfer files it works just fine, but if I send the server to a buddy and we try a file transfer he always gets the error "Run-time error '52': bad file name or number". Instead of using numfile I have simply tried numbers (#1, #2) but he still gets the same error. I dont understand why it would work locally but not over the internet. I have taken out " Close #numfile " completely and obviously didn't receive an error. Anyone have any ideas? Any help would be greatly appreciated! thank you
Last edited by Hack; Nov 21st, 2007 at 08:13 AM.
Reason: Added Highlight Tags
-
Nov 21st, 2007, 08:14 AM
#2
Re: File Transfer Help
Welcome to the forums.
I edited your post and added [highlight=vb]your code goes in here[/highlight] tags to make the code easier to read.
My first question whenever an issue like this arises is does your friend have the proper permissions to run against the internet server?
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
|