|
-
Aug 3rd, 1999, 09:34 AM
#1
Thread Starter
New Member
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
-
Nov 27th, 1999, 12:36 PM
#2
Lively Member
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|