Skip to content

Instantly share code, notes, and snippets.

@7sharp9
Created July 30, 2011 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7sharp9/1115343 to your computer and use it in GitHub Desktop.
Save 7sharp9/1115343 to your computer and use it in GitHub Desktop.
F# Web server
let server = HttpServer((fun(headers, close, svr, sd) ->
let header = sprintf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 20\r\nConnection: close\r\nServer: Fracture\r\nDate: %s\r\n\r\n" (DateTime.UtcNow.ToShortDateString())
let body = "Hello world.\r\nHello."
let encoded = System.Text.Encoding.ASCII.GetBytes(header + body)
do svr.Send(sd.RemoteEndPoint, encoded, true)), body = fun(body, svr, sd) ->
Debug.WriteLine( sprintf "%s" (Text.Encoding.ASCII.GetString(body.Array)) ) )
server.Listen(6667)
printfn "Http Server started"
Console.ReadKey() |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment