Web Server Hangs

Blitz3D Forums/Blitz3D Programming/Web Server Hangs

asdfasdf(Posted 2005) [#1]
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



Litobyte(Posted 2005) [#2]
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.


asdfasdf(Posted 2005) [#3]
sometimes it get past it. (rarly)


Rook Zimbabwe(Posted 2005) [#4]
Could it be a firewall problem?


Spencer(Posted 2008) [#5]
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


Spencer(Posted 2008) [#6]
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.