diff --git a/examples/2_dynamic_pdl/amy.c b/examples/2_dynamic_pdl/amy.c index 5a853ef2b5ed1f10c08331411edbddeb1b5d8654..f965c107d42368117f2b5f4ca7d39533142ed640 100644 --- a/examples/2_dynamic_pdl/amy.c +++ b/examples/2_dynamic_pdl/amy.c @@ -1,22 +1,14 @@ #include -#include #include #include "../../reowolf.h" #include "../utility.c" int main() { - - // amy's protocol is loaded at runtime from a file. - char * pdl = buffer_pdl("eg_protocols.pdl"); - char msg_buf[128]; - memset(msg_buf, 0, 128); - printf("input a message to send:"); - check("fgets", fgets(msg_buf, 128-1, stdin) == NULL); - int msg_len = strlen(msg_buf); - msg_buf[msg_len-1] = 0; - printf("will send msg `%s`\n", msg_buf); + // Protocol is loaded from file. + char * pdl = buffer_pdl("eg_protocols.pdl"); + // create a connector with one outgoing network channel. Connector* c = connector_new(); printf("configuring...\n"); check("config ", connector_configure(c, pdl, "forward")); @@ -25,16 +17,16 @@ int main() { printf("connecting...\n"); check("connect", connector_connect(c, 5000)); + // send "hello" message three times int i; for (i = 0; i < 3; i++) { - check("put ", connector_put(c, 0, msg_buf, msg_len)); + check("put ", connector_put(c, 0, "hello", 5)); check("sync", connector_sync(c, 1000)); printf("Sent one message!\n"); } - printf("destroying...\n"); + printf("cleaning up\n"); connector_destroy(c); - printf("exiting...\n"); free(pdl); return 0; } \ No newline at end of file