Results 1 to 4 of 4

Thread: Winsock file transfer issue (through Internet only?)

Threaded View

  1. #1

    Thread Starter
    New Member Inuya5ha's Avatar
    Join Date
    Mar 2006
    Location
    AR
    Posts
    7

    Question Winsock file transfer issue (through Internet only?)

    Hi, I'm using the Winsock OCX in VB6 to create a personal file server application, and it transfer files perfectly within the LAN, but not the Internet. If I access it via localhost or the machine name over LAN, it works perfect. But when accessing via the Internet IP, only the first block of the file arrives to the user's browser. However it is entirely sent, no errors appear in the server application.

    The main code to send the file is below, taken from DigiRev's Send File With Winsock code and modified to make it politely wait for the SendComplete event before sending the next chunk of data. Didn't fix the problem anyway.

    Code:
    Open FilePath For Binary Access Read As #lonFF
        
        ReDim bytData(1 To PacketSize) As Byte
        
        Do Until (lonSize - lonCurByte) < PacketSize
            Get #lonFF, lonCurByte + 1, bytData()
            lonCurByte = lonCurByte + PacketSize
            
            Do While sendComplete = False
                DoEvents '-- wait for the sendComplete event from winsock (using a flag)
            Loop
            
            Debug.Print SocketObject.State '-- show socket state (sckConnected)
            Debug.Print "Sending block " & lonCurByte
            
            sendComplete = False
            SocketObject.SendData bytData()
            DoEvents
        Loop
        
        lonPrevSize = lonSize - lonCurByte
        
        If lonPrevSize > 0 Then
            ReDim bytData(1 To lonPrevSize) As Byte
            Get #lonFF, lonCurByte + 1, bytData()
            lonCurByte = lonCurByte + lonPrevSize
            
            Do While sendComplete = False
                DoEvents '-- wait for the sendComplete event from winsock (using a flag)
            Loop
            
            Debug.Print SocketObject.State '-- show socket state (sckConnnected)
            Debug.Print "Sending final block..."
            
            sendComplete = False
            SocketObject.SendData bytData()
            DoEvents
        End If
    
    Close #lonFF
    Also tried with the UniSock API and the result is the same. And I used the Winsock repair utility just in case, of course it was useless. Also tried all possible block sizes: 1024, 2048, 4096, 8192... always the first block arrives to destination, and the browser keeps "Loading..." forever.

    ANY help wil be greatly appreciated. I'm not sending any headers before sending the file, I've tried that but didn't fix anything. And if it works OK over LAN, why it fails when accessing the server using the Internet IP?
    Last edited by Inuya5ha; Oct 11th, 2010 at 12:09 PM. Reason: code cleaning

Tags for this Thread

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