Advertisement
cheako

Example gnunet app.

Feb 21st, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <gnunet/platform.h>
  2.  
  3. #include <sys/select.h>
  4.  
  5. #include <sys/time.h>
  6. #include <sys/types.h>
  7. #include <unistd.h>
  8.  
  9. #include <gnunet/gnunet_util_lib.h>
  10.  
  11. static int ret;
  12.  
  13. static void run (void *cls, char *const *args, const char *cfgfile,
  14.         const struct GNUNET_CONFIGURATION_Handle *cfg) {
  15.  
  16.     struct sockaddr_in sa;
  17.     struct GNUNET_NETWORK_Handle *desc;
  18.  
  19.     memset (&sa, 0, sizeof (sa));
  20. #if HAVE_SOCKADDR_IN_SIN_LEN
  21.     sa.sin_len = sizeof (sa);
  22. #endif
  23.     sa.sin_family = AF_INET;
  24.     sa.sin_port = htons (6667);
  25.     sa.sin_addr.s_addr = inet_addr("127.0.0.1");
  26.     desc = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0);
  27.     GNUNET_assert (desc != NULL);
  28.     GNUNET_assert (GNUNET_OK == GNUNET_NETWORK_socket_bind
  29.             (desc, (struct sockaddr *) &sa, sizeof (sa)));
  30.     GNUNET_NETWORK_socket_listen (desc, 5);
  31.     ret = 0;
  32. }
  33.  
  34. int main (int argc, char *const *argv) {
  35.     static const struct GNUNET_GETOPT_CommandLineOption options[] = {
  36.         GNUNET_GETOPT_OPTION_END
  37.     };
  38.     return (GNUNET_OK == GNUNET_PROGRAM_run (
  39.         argc, argv, "gnunetircd",
  40.         gettext_noop ("ircd over gnunet"),
  41.         options, &run, NULL)) ? ret : 1;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement