Created
June 22, 2018 05:37
-
-
Save thedeemon/bbeaa06fe6768c7315a638fafee9cd28 to your computer and use it in GitHub Desktop.
Simple server returning same HTTP answer to all queries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "net" | |
class MyTCPConnectionNotify is TCPConnectionNotify | |
fun ref received(conn: TCPConnection ref, data: Array[U8] iso, times: USize) : Bool => | |
conn.write("HTTP/1.0 200 OK\nContent-Type: text/html; charset=utf-8\n\nOK\n") | |
conn.dispose() | |
false | |
fun ref connect_failed(conn: TCPConnection ref) => | |
None | |
class MyTCPListenNotify is TCPListenNotify | |
fun ref connected(listen: TCPListener ref): TCPConnectionNotify iso^ => | |
MyTCPConnectionNotify | |
fun ref not_listening(listen: TCPListener ref) => | |
None | |
actor Main | |
new create(env : Env) => | |
env.out.print("hi!") | |
try | |
let auth = env.root as AmbientAuth | |
TCPListener(auth, recover MyTCPListenNotify end, "", "8080") | |
else | |
env.out.print("unable to use the network") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment