how to get a SOCKET from a source



I've a small program that creates a listen endpoint, and registers a watch on it. when it goes ready I want to then call accept() against the listen_fd registered in the source.

gboolean  accept_connection(GIOChannel *source,
			    GIOCondition condition,
			    gpointer data) {
  SOCKET control_socket;
  SOCKET listen_socket;
  gboolean ret;

  g_print("accepting a new connection\n");

#ifdef G_OS_WIN32
  /* what is the call here? */

#else
  listen_socket = g_io_channel_unix_get_fd(source);
#endif

  control_socket = accept(listen_socket,NULL,0);
  if (control_socket == SOCKET_ERROR) {
    g_print("accept failed\n");
    exit(-1);
  }


the question of course, is how can I extract the SOCKET (listen_socket) which was previously registered:

#ifdef G_OS_WIN32
    control_channel = g_io_channel_win32_new_socket(listen_sock);
#else
    control_channel = g_io_channel_unix_new(listen_sock);
#endif

Based on an assumption of symmetry, I took a wild guess that it would be "g_io_channel_win32_get_socket" but that doesn't seem to be the case.

thanks,

rick jones



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]