Results 1 to 7 of 7

Thread: Winsock control web server 8k file limit

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Posts
    2

    Post

    I have a simple web server that works fine as long as the files it is serving do not exceede 8k. Any ideas?

    Dim DataSend
    Dim ExistFile
    SendingDataIndex(Index) = 1
    ExistFile = Dir(FileName$)
    If ExistFile > "" Then
    DataSend = DataSend & "HTTP/1.0 200 OK" & vbCrLf
    Else
    DataSend = DataSend & "HTTP/1.0 404 Not Found" & vbCrLf
    DataFile = "<body><h2>File Not Found</h2><br>" & vbCrLf
    DataFile = DataFile & " </body>" & vbCrLf
    End If
    DataSend = DataSend & "Server: ioCONTROL Server 1.0" & vbCrLf
    DataSend = DataSend & "Content-Type: " & ContentType$ & vbCrLf
    DataSend = DataSend & vbCrLf
    DataSend = DataSend & DataFile

    TCPSocket(Index).SendData DataSend

    If ExistFile > "" Then
    Dim FileExt$, FileType$: FileExt$ = LCase$(Right$(FileName$, 3))
    Select Case FileExt$
    Case "htm": FileType$ = "text/html"
    Case "txt": FileType$ = "text/plain"
    Case "gif": FileType$ = "image/gif"
    Case "jpg": FileType$ = "image/jpeg"
    Case "ass": FileType$ = "application/x-javascript"
    Case Else: FileType$ = "application/octet-stream"
    End Select
    Open FileName$ For Binary Access Read As Index

    Dim ChunkSize: ChunkSize = 16384
    Dim BytesToRead: BytesToRead = FileLen(FileName$)
    Do While BytesToRead > 0
    If BytesToRead < ChunkSize Then
    DataSend = Input(BytesToRead, Index)
    BytesToRead = 0
    Else
    DataSend = Input(ChunkSize, Index)
    BytesToRead = BytesToRead - ChunkSize
    End If
    TCPSocket(Index).SendData DataSend
    Loop
    Close Index

    End If

    'close the socket upon complete
    SendingDataIndex(Index) = 0


  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    ca, usa
    Posts
    91

    Post

    robp, I am to creating a simple web server and ran into the same problem, i found out that if you send a file to the host computer in chunks it thinks after the first chunk is recived and read that their is no more file to be read, so what i did is opened the file for binary as you did, and read the whole file into a string and sent it all at once, i was able to get 20k+ size files loaded and worked fine with now side effects, as of yet.

    tell me if this helped any via email.

    hoped this helps a bit
    Jeremy H.

    ------------------
    [email protected]

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Winsock control web server 8k file limit

    Did either of you to ever get this working?
    I am intregued as to why it only sends 8k

    Can you post any code?

    Woka

    PS This is the oldest post on VBF

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Winsock control web server 8k file limit

    Through the local network it is 8K usually, through the internet it really depends on the networkS it goes through, if one of the networks is max 1K chunk then all data your gonna receive will be in 1K chunks, not matter of the other networks, it is always the lowest chunk size of all of the networks from sending to receiving computers. Usually through internet the chink size should be ~ 4K (from my tests, a long time ago)

    It actually makes sense to me... lets say the file you send is 100GBytes (i'm exagerating of course), if you don't chunk the data, how are you gonna send a file that big ?
    How about if your streamming audio/video ? data gets sent continuosly, there is no end and beginning...

  5. #5
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Winsock control web server 8k file limit

    Quote Originally Posted by Wokawidget
    PS This is the oldest post on VBF
    Do you actually think this user is still using the VBF ? I really doubt it

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock control web server 8k file limit

    Where were you 5 years ago, WHEN THE QUESTION WAS ASKED?

  7. #7
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Winsock control web server 8k file limit

    Quote Originally Posted by CVMichael
    Through the local network it is 8K usually, through the internet it really depends on the networkS it goes through, if one of the networks is max 1K chunk then all data your gonna receive will be in 1K chunks, not matter of the other networks, it is always the lowest chunk size of all of the networks from sending to receiving computers. Usually through internet the chink size should be ~ 4K (from my tests, a long time ago)

    It actually makes sense to me... lets say the file you send is 100GBytes (i'm exagerating of course), if you don't chunk the data, how are you gonna send a file that big ?
    How about if your streamming audio/video ? data gets sent continuosly, there is no end and beginning...
    Yea, but you can build the "chunks" up into a big "chunk" and then validate it, or do whatever with it.

    Woka

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