Add socket operations
This commit is contained in:
11
examples/echoserver.monkey
Normal file
11
examples/echoserver.monkey
Normal file
@@ -0,0 +1,11 @@
|
||||
#!./monkey-lang
|
||||
|
||||
fd := socket("tcp4")
|
||||
bind(fd, "0.0.0.0:8000")
|
||||
listen(fd, 1)
|
||||
|
||||
nfd := accept(fd)
|
||||
msg := read(nfd)
|
||||
write(nfd, msg)
|
||||
close(nfd)
|
||||
close(fd)
|
||||
Reference in New Issue
Block a user