[gnet] gnet_tcp_socket_server_accept_async problem



Hi all,
here's a snip of my code:

===============================================
static void clientAccept (GTcpSocket* server, GTcpSocket* client, gpointer 
data) {
    if(client) {
        GInetAddr*  addr;
        gchar*      name;
        gint      port;

        gSocketChannel = gnet_tcp_socket_get_io_channel(client);
        g_io_add_watch(gSocketChannel, G_IO_IN | G_IO_OUT | G_IO_HUP | 
G_IO_ERR | G_IO_NVAL,(GIOFunc)SocketCB,NULL);
    } else {
        LOG_Write(LOG_FATAL,"[%s:%d] TCP Server error\n",__FILE__,__LINE__);
        exit(0);
    }
}

void main() {
...
gMainContext = (GMainContext *)g_main_context_new(); /* crea il contesto */
gMainLoop = (GMainLoop *)g_main_loop_new(gMainContext,FALSE); /* Crea il MAIN 
Loop */
gServerSock = gnet_tcp_socket_server_new_with_port(Modem->socket);
if(gServerSock == NULL) {
        exit(0);
}
gnet_tcp_socket_server_accept_async(gServerSock, clientAccept, NULL);
...
gTimerSource = (GSource *)g_timeout_source_new(1000);nd */
g_source_set_callback(gTimerSource,(GSourceFunc)ClockTimer,NULL,NULL);
gTimerID = g_source_attach(gTimerSource,gMainContext);

gLoopSource = (GSource *)g_timeout_source_new(200); /* Timer event every 
second */
g_source_set_callback(gLoopSource,(GSourceFunc)MainLoop,NULL,NULL);
g_source_attach(gLoopSource,gMainContext);
...
g_main_run(gMainLoop);
}

=======================================================

The program compile and run BUT, on telnet connection to socket, the function 
clientAccept will not be called !!!

Suggestions ? Thanks !
-- 
----
O-Zone ! No (C) 2005
WEB @ http://www.zerozone.it
BLOG @ http://blog.zerozone.it/user/o-zone



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