Private Sub PrepareServer
If serversock.IsInitialized Then serversock.Close
If astream.IsInitialized Then astream.Close
Do While True
Try
serversock.Initialize(port, "server")
serversock.Listen
Exit
Catch
port = port + 1
Log(LastException)
End Try
Loop
Wait For server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "astream")
Dim Response As StringBuilder
Response.Initialize
Do While Response.ToString.Contains("Host:") = False
Wait For AStream_NewData (Buffer() As Byte)
Response.Append(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
Loop
astream.Write(("HTTP/1.0 200" & Chr(13) & Chr(10)).GetBytes("UTF8"))
Sleep(50)
astream.Close
serversock.Close
ParseBrowserUrl(Regex.Split2("$",Regex.MULTILINE, Response.ToString)(0))
End If
End Sub