Socket server not reacting to clients



Hi,

I'm starting a socket server, but clients can't connect. The code already worked before, but doesn't seem to work now.
What could be wrong? Here is my code below.

Thanks,

JP


void listener_accept_async_function(GObject *source_object,
                          GAsyncResult *res,
                          gpointer user_data)
{
/* is not called at all (messages are not displayed) */

GuiStatusBarMessage(_("listener_accept_async_function: before finish\n")); ptSocketConnection = g_socket_listener_accept_finish(ptSocketListener,res,NULL,NULL); GuiStatusBarMessage(_("listener_accept_async_function: after finish\n"));
  SocketStartReadWrite();
}

gpointer SocketAcceptThread(gpointer data)
{
  do
    {
      ptSocket = NULL;
      ptSocketConnection = NULL;

if (Verbose_Flag) fprintf(stderr,"Waiting for incoming connection"); /* last message displayed */

g_socket_listener_accept_async(ptSocketListener,NULL,NULL,NULL);

/* the program keeps waiting here and doesn't seem to react to a connection. However, the client (another program) seems to have established a connection on the 2nd try; 1st one always fail. */

/* Wait here for an incoming connection while iterating the GTK main loop */ while (ptSocketConnection == NULL) g_main_context_iteration(NULL,FALSE);

/* program doesn't get here at all */

      GuiStatusBarMessage(_("Incoming connection"));
      if (Verbose_Flag) fprintf(stderr,"Incoming connection");

      /* Wait here to get the socket while iterating the GTK main loop */
      while (ptSocket == NULL) g_main_context_iteration(NULL,FALSE);

      GuiStatusBarMessage(_("Got socket"));
      if (Verbose_Flag) fprintf(stderr,"Got socket");

/* Wait here to check the connection result while iterating the GTK main loop */ while(g_socket_check_connect_result(ptSocket,NULL)) g_main_context_iteration(NULL,FALSE);

      GuiPortClose();
    }
  while(ptSocketAcceptThreadRunning);

  return NULL;
}




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