Files
@ 3ffeb97c88a7
Branch filter:
Location: CSY/reowolf/examples/interop_3_connector/main.c - annotation
3ffeb97c88a7
1.2 KiB
text/x-csrc
Add docs for implementing infinite types in a value based language.
Since we are a value based language and do not have the concept of
pointers, then if we want to lay out the memory of datatypes we run
into a problem when the types represent recursive datastructures:
these are infinite in size. So we have an algorithm for turning
some types into pointer-like things, such that we can lay everything
out in memory.
Since we are a value based language and do not have the concept of
pointers, then if we want to lay out the memory of datatypes we run
into a problem when the types represent recursive datastructures:
these are infinite in size. So we have an algorithm for turning
some types into pointer-like things, such that we can lay everything
out in memory.
673882671c9a 673882671c9a 673882671c9a 673882671c9a 673882671c9a a9fb2e3e41d9 a9fb2e3e41d9 8df425c3752e a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 18a1548e4a31 18a1548e4a31 18a1548e4a31 18a1548e4a31 18a1548e4a31 18a1548e4a31 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 18a1548e4a31 18a1548e4a31 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 a9fb2e3e41d9 8df425c3752e | /* This example demonstrates:
- connector API can create UDP mediator components, each given a BIND and CONNECT socket address,
which communicates via a returned putter and getter port pair.
- messages passed to the UDP mediator are forwarded as UDP datagrams into the network.
*/
#include <stdio.h>
#include <string.h>
#include "../../reowolf.h"
int main(int argc, char** argv) {
// --- setup ---
Arc_ProtocolDescription * pd = protocol_description_parse("", 0);
Connector * c = connector_new(pd);
PortId putter_a, putter_b;
FfiSocketAddr addresses[4] = {
{{127, 0, 0, 1}, 8000},
{{127, 0, 0, 1}, 8001},
{{127, 0, 0, 1}, 8002},
{{127, 0, 0, 1}, 8003},
};
// putter_a to UDP mediator (getter id discarded)
// with local addresses[0] and peer addresses[1]
connector_add_udp_mediator_component(c, &putter_a, NULL, addresses[1], addresses[0]);
connector_add_udp_mediator_component(c, &putter_b, NULL, addresses[3], addresses[2]);
connector_connect(c, -1);
// --- communication ---
connector_put_bytes(c, putter_a, "hello, socket!", 14);
connector_put_bytes(c, putter_b, "hello, pseudo-socket!", 21);
connector_sync(c, -1);
// --- cleanup ---
protocol_description_destroy(pd);
connector_destroy(c);
return 0;
}
|