/* 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 . */
#include
#include
#include
#include
#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);
}
}