2 #include <gnio/gsocket.h>
3 #include <gnio/ginetsocketaddress.h>
4 #include <gnio/ginet4address.h>
6 #include <glib/gprintf.h>
7 #include <sys/socket.h>
12 accept_callback (GSocket *socket, GAsyncResult *result, gpointer data)
16 if (!g_socket_connect_finish (socket, result, &error)) {
17 g_warning (error->message);
21 g_print ("successfully connected\n");
24 int main (int argc, char *argv[])
32 loop = g_main_loop_new (NULL, FALSE);
34 socket = g_socket_new (G_SOCKET_DOMAIN_INET, G_SOCKET_TYPE_STREAM, NULL, NULL);
36 g_printf ("connecting to 127.0.0.1:31882...\n");
38 g_socket_connect_async (socket, G_SOCKET_ADDRESS (g_inet_socket_address_new (G_INET_ADDRESS (g_inet4_address_from_string ("127.0.0.1")), 31882)), NULL, (GAsyncReadyCallback) accept_callback, NULL);
40 g_main_loop_run (loop);