diff options
Diffstat (limited to 'examples/threaded-example.c')
-rw-r--r-- | examples/threaded-example.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/threaded-example.c b/examples/threaded-example.c index e672d89..2564b3a 100644 --- a/examples/threaded-example.c +++ b/examples/threaded-example.c @@ -41,10 +41,11 @@ #include <stdio.h> #include <string.h> #include <ctype.h> -#include <unistd.h> #include <agent.h> +#include <gio/gnetworking.h> + static GMainLoop *gloop; static gchar *stun_addr = NULL; static guint stun_port; @@ -104,6 +105,7 @@ main(int argc, char *argv[]) #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); #endif + g_networking_init(); gloop = g_main_loop_new(NULL, FALSE); @@ -129,7 +131,11 @@ example_thread(void *data) gchar *line = NULL; int rval; +#ifdef G_OS_WIN32 + io_stdin = g_io_channel_win32_new(_fileno(stdin)); +#else io_stdin = g_io_channel_unix_new(fileno(stdin)); +#endif g_io_channel_set_flags (io_stdin, G_IO_FLAG_NONBLOCK, NULL); // Create the nice agent @@ -202,7 +208,7 @@ example_thread(void *data) } g_free (line); } else if (s == G_IO_STATUS_AGAIN) { - usleep (100000); + g_usleep (100000); } } @@ -238,7 +244,7 @@ example_thread(void *data) printf("> "); fflush (stdout); } else if (s == G_IO_STATUS_AGAIN) { - usleep (100000); + g_usleep (100000); } else { // Ctrl-D was pressed. nice_agent_send(agent, stream_id, 1, 1, "\0"); |