aboutsummaryrefslogtreecommitdiff
path: root/examples/client.sloth
diff options
context:
space:
mode:
Diffstat (limited to 'examples/client.sloth')
-rw-r--r--examples/client.sloth21
1 files changed, 16 insertions, 5 deletions
diff --git a/examples/client.sloth b/examples/client.sloth
index 8b7f737..26a902f 100644
--- a/examples/client.sloth
+++ b/examples/client.sloth
@@ -1,9 +1,20 @@
fn main() Int {
- var sockint: Int = clientsock();
+ var sockint: Int = clientsock(8080, "127.0.0.1");
println(recvsock(sockint));
- while true {
- sendsock(readln(), sockint);
- }
- closesock(sockint);
+ var con: Bool = true;
+ while con == true {
+ print("send> ");
+ var msg: String = readln();
+ sendsock(msg, sockint);
+ if sequals(msg, "KILLCLIENT") {
+ con = false;
+ }
+ println("wait...");
+ msg = recvsock(sockint);
+ print("server: ");
+ println(msg);
+
+ }
+ closesock(sockint, false);
return 0;
}