Files
@ 28df9835906f
Branch filter:
Location: CSY/reowolf/examples/interop_3_connector/main.c - annotation
28df9835906f
1.2 KiB
text/x-csrc
Reimplement namespaced identifier to support polymorphic args
This is somewhat of a temporary hack, as a namespaced identifier should
not really refer to types or polymorphic arguments. But we need a
tokenizer and a prepass to properly distinguish identifiers from types.
So it works, but error messages may be cryptic.
This is somewhat of a temporary hack, as a namespaced identifier should
not really refer to types or polymorphic arguments. But we need a
tokenizer and a prepass to properly distinguish identifiers from types.
So it works, but error messages may be cryptic.
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;
}
|