summaryrefslogtreecommitdiff
path: root/src/tools/echo
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-21 21:12:03 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-21 21:12:03 +0200
commitf0d4305c067044e74c44032c32ce6c4db3c6fffa (patch)
treed895b25fb5a8f7af106c6c2d3228b62ade81b3b4 /src/tools/echo
parentba27593e3e8406e109393ae383f17c7416675c1e (diff)
parentcee5ae97ee14438b2dabc06bfad9b02e42e4d816 (diff)
downloadouroboros-f0d4305c067044e74c44032c32ce6c4db3c6fffa.tar.gz
ouroboros-f0d4305c067044e74c44032c32ce6c4db3c6fffa.zip
Merged in dstaesse/ouroboros/be-irmd-refactor (pull request #213)
irmd, lib: Rebuild the IRMd data model
Diffstat (limited to 'src/tools/echo')
-rw-r--r--src/tools/echo/echo.c24
-rw-r--r--src/tools/echo/echo_server.c5
2 files changed, 16 insertions, 13 deletions
diff --git a/src/tools/echo/echo.c b/src/tools/echo/echo.c
index ab7d5557..28ae4c1a 100644
--- a/src/tools/echo/echo.c
+++ b/src/tools/echo/echo.c
@@ -41,19 +41,15 @@ static void usage()
int main(int argc, char ** argv)
{
int ret = -1;
- if (ap_init(argv[0])) {
- printf("Failed to init AP.\n");
- return -1;
- }
+ char ** argv_dup = argv;
+ bool server = false;
argc--;
argv++;
while (argc > 0) {
if (strcmp(*argv, "-l") == 0 ||
strcmp(*argv, "--listen") == 0) {
- ret = server_main();
- ap_fini();
- return ret;
+ server = true;
} else {
usage();
return 0;
@@ -62,7 +58,19 @@ int main(int argc, char ** argv)
argv++;
}
- ret = client_main();
+ if (server) {
+ if (ap_init(argv_dup[0])) {
+ printf("Failed to init AP.\n");
+ return -1;
+ }
+ ret = server_main();
+ } else {
+ if (ap_init(NULL)) {
+ printf("Failed to init AP.\n");
+ return -1;
+ }
+ ret = client_main();
+ }
ap_fini();
diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c
index 3106ee35..e6ab9cfd 100644
--- a/src/tools/echo/echo_server.c
+++ b/src/tools/echo/echo_server.c
@@ -39,11 +39,6 @@ int server_main()
char buf[BUF_SIZE];
ssize_t count = 0;
- if (api_bind(NULL) < 0) {
- printf("Failed to bind the server api.");
- return -1;
- }
-
printf("Starting the server.\n");
/* Manual cleanup is required for now */