aboutsummaryrefslogtreecommitdiff
path: root/examples/server.sloth
diff options
context:
space:
mode:
authorNic Gaffney <gaffney_nic@protonmail.com>2023-06-29 01:47:35 -0500
committerNic Gaffney <gaffney_nic@protonmail.com>2023-06-29 01:47:35 -0500
commitc8a987daefa1475b1902b9823e8d2ef4500943cd (patch)
tree6b4d83afc7daee73d4560e0049fb4f83e8a843a4 /examples/server.sloth
parentdd3906c96555805af2580d593cf9429170b07a02 (diff)
downloadsloth-c8a987daefa1475b1902b9823e8d2ef4500943cd.tar.gz
Sockets update
Diffstat (limited to 'examples/server.sloth')
-rw-r--r--examples/server.sloth12
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/server.sloth b/examples/server.sloth
index 201f8a2..3329471 100644
--- a/examples/server.sloth
+++ b/examples/server.sloth
@@ -1,14 +1,20 @@
fn main() Int {
- var sockint: Int = serversock();
+ var sockint: Int = serversock(8080, "auto", 10);
+ println("slothnet has initialized!");
sendsock("Welcome to slothnet!", sockint);
var con: Bool = true;
while con == true {
+ println("wait...");
var msg: String = recvsock(sockint);
+ print("client: ");
println(msg);
- if sequals(msg, "kill") {
+ print("send> ");
+ msg = readln();
+ sendsock(msg, sockint);
+ if sequals(msg, "KILLSERV") {
con = false;
}
}
- closesock(sockint);
+ closesock(sockint, true);
return 0;
}