aboutsummaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-06 17:00:25 -0400
committerDeterminant <[email protected]>2019-06-06 17:00:25 -0400
commitf32e3109526f2d4e980c03dd65f7c94edff4d2b2 (patch)
tree990cd76066550bb6402e5c85d462ce86a570beb0 /demo
init
Diffstat (limited to 'demo')
-rw-r--r--demo/main.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/demo/main.go b/demo/main.go
new file mode 100644
index 0000000..e156f45
--- /dev/null
+++ b/demo/main.go
@@ -0,0 +1,23 @@
+package main
+
+import "salticidae-go"
+
+func run(my_addr string, other_addr string) {
+ netconfig := salticidae.NewMsgNetworkConfig()
+ ec := salticidae.NewEventContext()
+ net := salticidae.NewMsgNetwork(ec, netconfig)
+ listen_addr := salticidae.NewAddrFromIPPortString(my_addr)
+ connect_addr := salticidae.NewAddrFromIPPortString(other_addr)
+
+ net.Start()
+ net.Listen(listen_addr)
+ net.Connect(connect_addr)
+ ec.Dispatch()
+}
+
+func main() {
+ alice := "127.0.0.1:10000"
+ bob := "127.0.0.1:10001"
+ go run(alice, bob)
+ run(bob, alice)
+}