it begindth
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
.eunit
|
||||
deps
|
||||
*.o
|
||||
*.beam
|
||||
*.plt
|
||||
*.swp
|
||||
*.swo
|
||||
erl_crash.dump
|
||||
ebin/*.beam
|
||||
doc/*.html
|
||||
doc/*.css
|
||||
doc/edoc-info
|
||||
doc/erlang.png
|
||||
rel/example_project
|
||||
.concrete/DEV_MODE
|
||||
.rebar
|
||||
@@ -0,0 +1,9 @@
|
||||
# rubicon mega-repo and playground
|
||||
|
||||
## rubicon by example
|
||||
|
||||
- x00-hello:
|
||||
- purpose: hello world with noise
|
||||
- client connects to server
|
||||
- server writes back "hello"
|
||||
- server closes connection
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Rubicon contracts
|
||||
*
|
||||
* Copyright (C) 2026, QPQ AG
|
||||
*
|
||||
* Author: Peter Harpending <peterharpending@qpq.swiss>
|
||||
* Date: 2026-08-12
|
||||
*/
|
||||
|
||||
payable contract NameService =
|
||||
record state =
|
||||
{names : map(string, address)}
|
||||
|
||||
payable entrypoint
|
||||
init : () => state
|
||||
init() =
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-module(hello_client).
|
||||
|
||||
-export([main/0]).
|
||||
|
||||
main() ->
|
||||
{ok, Socket} = gen_tcp:connect("localhost", 6969, [binary, {packet, 0}]),
|
||||
loop(Socket).
|
||||
|
||||
loop(Socket) ->
|
||||
ok = inet:setopts(Socket, [{active, once}]),
|
||||
receive
|
||||
{tcp, Socket, Bytes} ->
|
||||
ok = io:format("< ~tp~n", [Bytes]),
|
||||
loop(Socket);
|
||||
{tcp_closed, Socket} ->
|
||||
ok = io:format("connection terminated~n", []),
|
||||
exit(normal)
|
||||
end.
|
||||
@@ -0,0 +1,14 @@
|
||||
-module(hello_server).
|
||||
|
||||
-export([main/0]).
|
||||
|
||||
main() ->
|
||||
{ok, ListenSocket} = gen_tcp:listen(6969, [binary, {packet, 0}, {active, false}]),
|
||||
%% blocks until client connects
|
||||
{ok, Socket} = gen_tcp:accept(ListenSocket),
|
||||
Msg = <<"hello, world">>,
|
||||
ok = io:format("> ~tp~n", [Msg]),
|
||||
ok = gen_tcp:send(Socket, Msg),
|
||||
ok = gen_tcp:close(Socket),
|
||||
ok = gen_tcp:close(ListenSocket),
|
||||
ok.
|
||||
Reference in New Issue
Block a user