Results 1 to 5 of 5

Thread: Winsock - Transfer File

Threaded View

  1. #1

    Thread Starter
    Member LoopUntil's Avatar
    Join Date
    Jul 2008
    Posts
    58

    Winsock - Transfer File

    I'm trying to transfer a simple file between a client and a server but It doesnt work... The sended file (ceta1.exe) must be 16kb but Its only 8kb.

    I tryed to debug and I saw that the server use the Put function only 2 times.

    What can be the problem?!


    CLIENT:

    Code:
    Private Sub Command1_Click()
    Winsock1.Close
    Winsock1.Connect Text1.Text, Text2.Text
    End Sub
    
    Private Sub Command2_Click()
    Dim datatosend As String
    Dim conteggio As Long
    
    datatosend = Space(4000)
    
    Open Text3.Text For Binary As #1
    For conteggio = 0 To CLng(LOF(1) / 4000)
    Get #1, conteggio * CLng(4000) + 1, datatosend
    Winsock1.SendData datatosend
    Next conteggio
    Close #1
    
    End Sub
    
    Private Sub Command3_Click()
    cmn1.ShowOpen
    Text3.Text = cmn1.FileName
    End Sub
    
    
    Private Sub Form_Load()
    Text1.Text = Winsock1.LocalIP
    End Sub

    SERVER:

    Code:
    Private Sub Form_Load()
    Winsock1.Listen
    End Sub
    
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Winsock1.Close
    Winsock1.Accept requestID
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    
    Winsock1.GetData data
    
    Open "C:\ceta1.exe" For Binary As #1
    Put #1, , data
    Close #1
    End Sub


    P.S. I know that there are a lot of topics and sources on the forum about this but I want to do it by myself because the other programs are too complicated
    Last edited by LoopUntil; Aug 2nd, 2008 at 09:26 AM.

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