Private Sub PrepareServer
If server.IsInitialized Then server.Close
If astream.IsInitialized Then astream.Close
Do While True
Try
server.Initialize(port, "server")
server.Listen
Exit
Catch
port = port + 1
Log(LastException)
End Try
Loop
Wait For server_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("This was executed(server_NewConnection="&Successful&")...")
If Successful Then
astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "AStream")'<---My only change in this function was to change "astream" to "AStream"
Dim Response As StringBuilder
Response.Initialize
Log("Here we go...")
Do While Response.ToString.Contains("Host:") = False
Log("I'm here...")
Wait For AStream_NewData (Buffer() As Byte) '<--- From this point does not follow, I have to clarify that there are times that if it works
Response.Append(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
Loop
Log("I pass the loop...")
astream.Write(("HTTP/1.0 200" & Chr(13) & Chr(10)).GetBytes("UTF8"))
Sleep(50)
astream.Close
server.Close
ParseBrowserUrl(Regex.Split2("$",Regex.MULTILINE, Response.ToString)(0))
End If
End Sub