diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/client.sloth | 9 | ||||
| -rw-r--r-- | examples/server.sloth | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/examples/client.sloth b/examples/client.sloth new file mode 100644 index 0000000..8b7f737 --- /dev/null +++ b/examples/client.sloth @@ -0,0 +1,9 @@ +fn main() Int { + var sockint: Int = clientsock(); + println(recvsock(sockint)); + while true { + sendsock(readln(), sockint); + } + closesock(sockint); + return 0; +} diff --git a/examples/server.sloth b/examples/server.sloth new file mode 100644 index 0000000..201f8a2 --- /dev/null +++ b/examples/server.sloth @@ -0,0 +1,14 @@ +fn main() Int { + var sockint: Int = serversock(); + sendsock("Welcome to slothnet!", sockint); + var con: Bool = true; + while con == true { + var msg: String = recvsock(sockint); + println(msg); + if sequals(msg, "kill") { + con = false; + } + } + closesock(sockint); + return 0; +} |
