Beispiel #1
0
int
main(int argc, char** argv)
{
  int port = 8123;
  GNetXmlRpcServer *server;
  GMainLoop* main_loop;

  Tcl_FindExecutable(argv[0]);
  gnet_init ();

  if (argc > 1)
      port = atoi(argv[1]);

  /* Create the main loop */
  main_loop = g_main_new (FALSE);

  server = gnet_xmlrpc_server_new(port);

  printf("port = %d\n", port);
  
  if (!server)
    {
      fprintf (stderr, "Error: Could not start server\n");
      exit (EXIT_FAILURE);
    }

  tcl_interp = Tcl_CreateInterp();
  Tcl_Init(tcl_interp);
  Tcl_CreateCommand(tcl_interp, "ping",
                    tcl_ping, (ClientData) NULL,
                    (Tcl_CmdDeleteProc *) NULL);

  gnet_xmlrpc_server_register_command(server,
				      "ping",
				      xmlrpc_cmd_ping,
				      NULL);

  gnet_xmlrpc_server_register_command(server,
				      "cmd",
				      xmlrpc_cmd_tcl,
				      NULL);

  /* Start the main loop */
  g_main_run(main_loop);

  exit (EXIT_SUCCESS);
  return 0;
}
int
main(int argc, char** argv)
{
  int port = 8123;
	gchar* addr = "localhost";
  GNetXmlRpcServer *server;
  GMainLoop* main_loop;

  gnet_init ();

  if (argc > 1)
      port = atoi(argv[1]);

  /* Create the main loop */
  main_loop = g_main_loop_new (NULL,
                               FALSE);

  server = gnet_xmlrpc_server_new(addr, port);

  if (!server)
    {
      fprintf (stderr, "Error: Could not start server\n");
      exit (EXIT_FAILURE);
    }

  gnet_xmlrpc_server_register_command(server,
				      "foo",
				      do_foo,
				      NULL);

  gnet_xmlrpc_server_register_command(server,
				      "echo",
				      do_echo,
				      NULL);
  
  gnet_xmlrpc_server_register_async_command(server,
				      "async",
				      do_async,
				      NULL);

  /* Start the main loop */
  g_main_loop_run(main_loop);

  exit (EXIT_SUCCESS);
  return 0;
}