Add socket operations
Some checks failed
Build / build (push) Failing after 6m15s
Test / build (push) Failing after 6m6s

This commit is contained in:
Chuck Smith
2024-03-28 14:11:51 -04:00
parent 67c5b4cd66
commit fd8311b280
11 changed files with 325 additions and 5 deletions

View File

@@ -0,0 +1,8 @@
#!./monkey-lang
fd := socket("tcp4")
bind(fd, "127.0.0.1:32535")
connect(fd, "127.0.0.1:8000")
write(fd, "Hello World")
print(read(fd))
close(fd)

View 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)