Skip to content

Instantly share code, notes, and snippets.

@mopemope
Created October 6, 2011 07:57
Show Gist options
  • Save mopemope/1266795 to your computer and use it in GitHub Desktop.
Save mopemope/1266795 to your computer and use it in GitHub Desktop.
EchoServer
import threading/Thread
import net/ServerSocket
main: func {
socket := ServerSocket new("0.0.0.0", 5000)
socket listen(100)
while(true){
conn := socket accept()
Thread new (||
while(true){
buf:Char[256]
ret := conn sock receive(buf as Char*, 256, 0)
if(!conn sock hasData?){
break
}
conn sock send(buf as Char*, ret, 0, false)
}
conn close()
) start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment