Web Server Hangs
Blitz3D Forums/Blitz3D Programming/Web Server Hangs
| ||
| I'm making a web server for a SSH Tunneling hardware box. It hangs when it sends a js file. Output: GET \ HTTP\1.1 Sent: login.htm GET \login_log.js HTTP\1.1 Program hangs here. It won't send.
;;;;;;;;;;;;;;;;;;;;;;;;;;
;SSH Tunneling Server Box;
;;;;;;;;;;;;;;;;;;;;;;;;;;
AppTitle "SSH Tunneling Server Box"
Global admin_pass = "admin"
Global http = CreateTCPServer(80) ;Create the online website
Global ssh = CreateTCPServer(22) ;Create the SSH Tunneling server
Global httpstream
If http = 0 Then
;Light error light here
ElseIf ssh = 0 Then
;Light error light here
EndIf
While Not KeyHit(1)
httpstream = AcceptTCPStream(http)
If httpstream Then
R_line$ = ReadLine$(httpstream)
Print R_line$
If Mid$(R_line$,5,2) = "/ " Then
If FileType("login.htm") = 0 Then
Color 255,0,0
Print "Error! Missing File."
Color 255,255,255
EndIf
SendFile("login.htm")
Else
If FileType(Mid$(R_line$,6,Len(R_Line$) - 14)) = 0 Then
Color 255,0,0
Print "Error! Missing File."
Color 255,255,255
EndIf
SendFile(Mid$(R_line$,6,Len(R_Line$) - 14))
EndIf
CloseTCPStream httpstream
httpstream = 0
EndIf
sshstream = AcceptTCPStream(ssh)
If sshstream Then
WriteLine sshstream,"Shoo. Were aren't accepting ssh connections!"
CloseTCPStream sshstream
sshstream = 0
EndIf
Wend
CloseTCPServer http
CloseTCPServer ssh
Function SendFile(filepath$)
file = ReadFile(filepath$)
While Not Eof(file)
WriteLine httpstream,ReadLine$(file)
Wend
CloseFile(file)
WriteLine httpstream,""
Color 0,255,0
Print "Sent: " + filepath$
Color 255,255,255
End Function
|
| ||
| Maybe a security problem ? Super WinXP Smart Edition will reconize the malicious code in the .js and stop the spider in charge of deliver the packets. Just a guess. |
| ||
| sometimes it get past it. (rarly) |
| ||
| Could it be a firewall problem? |
| ||
| Function Server() Local TCPServer = CreateTCPServer(80) Local IncomingTCPStream Print "Server started" While Not KeyHit(1) IncomingTCPStream = AcceptTCPStream(TCPServer) If IncomingTCPStream Then For x = 1 To 9 Print ReadLine$(IncomingTCPStream) Next WriteLine IncomingTCPStream , "HTTP/1.0 200 OK" WriteLine IncomingTCPStream , "Connection: Close" WriteLine IncomingTCPStream , "" WriteLine(IncomingTCPStream , "<html> Hello world </html>") WriteLine IncomingTCPStream , "" CloseTCPStream(IncomingTCPStream) End If Wend End Function |
| ||
| I think you need perform a "hand shake" of sorts with the web browser. The For loop simply reads thru the information Internet Explorer 7 sends to the web server when requesting a webpage. |