Results 1 to 11 of 11

Thread: [RESOLVED] Trying winsock File Transfer (RESOLVED)

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Trying winsock File Transfer (RESOLVED)

    Hi,

    I had a go today at making my own file transfer example. This is what I have so far but I can't get in to work properly. What code do I need to add?


    VB Code:
    1. 'Client Code
    2. Dim file As String
    3. Dim Blocksize As Long
    4. Dim NF As Integer
    5.  
    6. Private Sub Command1_Click()
    7. CommonDialog1.ShowOpen
    8. Text1.Text = CommonDialog1.FileTitle
    9. End Sub
    10.  
    11. Private Sub Command2_Click()
    12. Winsock1.Connect "127.0.0.1", "7000"
    13. End Sub
    14.  
    15. Private Sub Command3_Click()
    16. NF = FreeFile
    17. Open CommonDialog1.filename For Binary Access Read As #NF
    18. file = Space$(Blocksize)
    19. Get #NF, , file
    20. Do Until EOF(NF)
    21. Winsock1.SendData file
    22. Loop
    23. Close #NF
    24. End Sub
    25.  
    26. 'Server Code
    27. Dim file As String
    28. Dim dat As String
    29. Dim NF As Integer
    30. Private Sub Form_Load()
    31. Winsock1.LocalPort = 7000
    32. Winsock1.Listen
    33. End Sub
    34.  
    35. Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    36. If Winsock1.State <> sckClosed Then Winsock1.Close
    37. Winsock1.Accept requestID
    38. End Sub
    39.  
    40. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    41. On Error Resume Next
    42. Winsock1.GetData dat
    43. If InStr(1, dat, "|DATA|") <> 0 Then
    44. NF = FreeFile
    45. Open App.Path & "\test.exe" For Binary Access Write As #NF
    46. Put #NF, , file
    47. Close #NF
    48. End If
    49. End Sub

    Please give me some help to point me in the right direction.

    TIA

    NW
    Last edited by Nightwalker83; Apr 1st, 2003 at 04:30 AM.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width