Re: dynamic socket descriptor management



On Wednesday 19 May 2004 03:46, Frank W. Miller wrote:

Hi,

I've got a multi-threaded softphone GNOME client up and limping.
I'm having some trouble writing to a socket.  The client seems to lock
up when I try to do it from a thread.  I'm wondering whether I need to
make use of gtk_input_add().  Trouble is, the socket I want to write to
is "dynamic".  This means the user can change UDP ports and therefore
cause the socket to be opened and closed on demand.  What are the
implications for GNOME for doing this?  I've read that gtk_input_add()
needs to be called before gtk_main().  This would clearly be violated by
what I'm trying to do.


I don't really have a direct answer to your question, but I wonder if you had 
seen GNet (http://www.gnetlibrary.org). 

Their GUdpSocket interface is dead easy to use and ties in nicely with the 
Gtk/Gnome main loop stuff (either you regularly poll the socket with 
gnet_udp_has_packet(), or you get the GIOChannel of the UDP socket and add a 
watch with g_io_add_watch(), so your callback is called whenever a packet has 
been received or the socket is ready for writing).
  
   http://www.gnetlibrary.org/docs/gnet-udp.html

(It should be fairly easy to rip out the relevant files from the GNet source 
in case you don't want to depend on it).

Cheers
 -Tim



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