forked from Orchid/orchid
Initial networking module.
This commit is contained in:
13
examples/tcp-client/src/main.orc
Normal file
13
examples/tcp-client/src/main.orc
Normal file
@@ -0,0 +1,13 @@
|
||||
import std::socket::tcp::(connect, read, write_all, close, peer_addr)
|
||||
import system::io::println
|
||||
|
||||
const main := do cps {
|
||||
cps conn = connect "127.0.0.1:8080";
|
||||
cps addr = peer_addr conn;
|
||||
cps println $ "Connected to ${addr}";
|
||||
cps _ = write_all conn "Hello from Orchid!\n";
|
||||
cps response = read conn 1024;
|
||||
cps println $ "Server response: ${response}";
|
||||
cps _ = close conn;
|
||||
cps pass 0;
|
||||
}
|
||||
Reference in New Issue
Block a user