summaryrefslogtreecommitdiff
path: root/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'ping.c')
-rw-r--r--ping.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/ping.c b/ping.c
new file mode 100644
index 0000000..32a2fb8
--- /dev/null
+++ b/ping.c
@@ -0,0 +1,73 @@
+/* A pong client.
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+ This file might one day be a part of the GNU Hurd.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <error.h>
+#include <hurd.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "reincarnation.h"
+
+#include "pong_U.h"
+#include "reincarnation_U.h"
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+
+ if (argc != 2)
+ error (1, 0, "Usage: %s PONG-SERVER", argv[0]);
+
+ /* Get reincarnation port. */
+ mach_port_t reincarnation;
+ err = reincarnation_get_port (mach_task_self (),
+ &reincarnation);
+ if (err)
+ error (1, err, "reincarnation_get_port");
+
+ if (reincarnation != MACH_PORT_NULL)
+ {
+ /* Get reincarnation image. */
+ char *image = NULL;
+ size_t image_len = 0;
+ err = reincarnation_reincarnate (reincarnation, &image, &image_len);
+ if (err)
+ error (1, err, "reincarnation_reincarnate");
+ }
+
+ mach_port_t pong = file_name_lookup (argv[1], 0, 0);
+ if (pong == MACH_PORT_NULL)
+ error (1, errno, "file_name_lookup");
+
+ while (1)
+ {
+ int local;
+ int global;
+ err = ping (pong, &local, &global);
+ if (err)
+ error (1, err, "ping");
+
+ printf ("local: % 4i\tglobal: % 4i\n", local, global);
+
+ sleep (1);
+ }
+}