[gnet] Global questions


I'm quite new to network programming under Unix and I'm developping a
server that acts as a kind of «gateway» between a client (written in
Flash and using ActionScript) and a database (PostGreSQL).
The client sends XML streams to the server and the latter parses and
analyzes the streams. It then contacts the database in order to do
various operations. 
It really is a classical schema.

The server must handle multiple connections at a time, so I've decided
to user a GServer structure to implement it. I'm keeping a reference of
each new GConn that it handles in a list.

My questions are :
1) I want to use threads for each new connection, that is, the server is
asynchronous (GServer makes asynchronous I/O, does it ?) and everytime
there's a new connection, I start a new thread and do the necessary job
for this connection. Is it the right way to handle multiple connections
in a threaded app ?
2) Sometimes (not always), I have to send a message back to one or more
connections (that's why I keep reference to them). I've seen that there
is a function named «gnet_conn_set_watch_writable ()» to watch if data
can be send to the socket. How do I use this ? Must I also set a
callback for the GNET_CONN_WRITABLE event ? I see it like this :

	gnet_conn_set_callback (connection, my_callback, my_datas);
	gnet_conn_set_watch_writable(connection, TRUE);
Is it correct ?

Dusausoy Bruno <bdusauso beeznest net>

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