PDA

Click to See Complete Forum and Search --> : Winsock control web server 8k file limit


robp
Aug 3rd, 1999, 09:34 AM
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

Dafly
Nov 27th, 1999, 11:36 AM
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.

------------------
Dafly98@aol.com

Wokawidget
Jan 18th, 2005, 05:37 PM
Did either of you to ever get this working?
I am intregued as to why it only sends 8k :confused:

Can you post any code?

Woka

PS This is the oldest post on VBF :D

CVMichael
Jan 18th, 2005, 06:40 PM
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...

CVMichael
Jan 18th, 2005, 06:43 PM
PS This is the oldest post on VBF :D
Do you actually think this user is still using the VBF ? I really doubt it

dglienna
Jan 18th, 2005, 06:44 PM
Where were you 5 years ago, WHEN THE QUESTION WAS ASKED? :wave:

Wokawidget
Jan 18th, 2005, 08:23 PM
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