From 6d48d6b911510be46782628704b6abb530fabbf8 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Thu, 13 Aug 2026 21:02:09 -0600 Subject: [PATCH] it begindth --- .gitignore | 16 ++++++++++++++++ README.md | 9 +++++++++ ct/rubicon.aes | 17 +++++++++++++++++ x00-hello/hello_client.erl | 18 ++++++++++++++++++ x00-hello/hello_server.erl | 14 ++++++++++++++ 5 files changed, 74 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ct/rubicon.aes create mode 100644 x00-hello/hello_client.erl create mode 100644 x00-hello/hello_server.erl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bfb900 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b98763 --- /dev/null +++ b/README.md @@ -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 diff --git a/ct/rubicon.aes b/ct/rubicon.aes new file mode 100644 index 0000000..e253e65 --- /dev/null +++ b/ct/rubicon.aes @@ -0,0 +1,17 @@ +/** + * Rubicon contracts + * + * Copyright (C) 2026, QPQ AG + * + * Author: Peter Harpending + * Date: 2026-08-12 + */ + +payable contract NameService = + record state = + {names : map(string, address)} + + payable entrypoint + init : () => state + init() = + diff --git a/x00-hello/hello_client.erl b/x00-hello/hello_client.erl new file mode 100644 index 0000000..a212e2c --- /dev/null +++ b/x00-hello/hello_client.erl @@ -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. diff --git a/x00-hello/hello_server.erl b/x00-hello/hello_server.erl new file mode 100644 index 0000000..6876dbb --- /dev/null +++ b/x00-hello/hello_server.erl @@ -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.