Mercurial > pidgin.yaz
diff src/network.h @ 12909:8e3b85fe4a55
[gaim-migrate @ 15262]
Make UPnP truly asynchronous.
There are probably still a couple socket calls that should be made nonblocking, but I wanted to commit this before it became even bigger. This contains a number of probable leak fixes in the upnp stuff.
The UPnP stuff has been updated to use gaim_url_fetch_request() instead of the specific implementation.
To make this all work, I had to make gaim_network_listen() and gaim_network_listen_range() also asynchronous - seems to work just fine apart from the UPnP calls seeming to take longer than they should (I'm planning to look into this).
I also triggered a STUN and UPnP discovery on startup so that we hopefully have the information when we need it.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 17 Jan 2006 05:48:51 +0000 |
parents | d5b8f4dc1622 |
children | b7b31c69ade6 |
line wrap: on
line diff
--- a/src/network.h Tue Jan 17 05:20:38 2006 +0000 +++ b/src/network.h Tue Jan 17 05:48:51 2006 +0000 @@ -34,6 +34,8 @@ /**************************************************************************/ /*@{*/ +typedef void (*GaimNetworkListenCallback) (int listenfd, gpointer data); + /** * Converts a dot-decimal IP address to an array of unsigned * chars. For example, converts 192.168.0.1 to a 4 byte @@ -109,19 +111,24 @@ * would want to do that is beyond me. * * This opens a listening port. The caller will want to set up a watcher - * of type GAIM_INPUT_READ on the returned fd. It will probably call - * accept in the callback, and then possibly remove the watcher and close + * of type GAIM_INPUT_READ on the fd returned in cb. It will probably call + * accept in the watcher callback, and then possibly remove the watcher and close * the listening socket, and add a new watcher on the new socket accept * returned. * * @param port The port number to bind to. Must be greater than 0. * @param socket_type The type of socket to open for listening. * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP. + * @param cb The callback to be invoked when the port to listen on is available. + * The file descriptor of the listening socket will be specified in + * this callback, or -1 if no socket could be established. + * @param cb_data extra data to be returned when cb is called * - * @return The file descriptor of the listening socket, or -1 if - * no socket could be established. + * @return TRUE if the callback will be invoked, or FALSE if unable to obtain + * a local socket to listen on. */ -int gaim_network_listen(unsigned short port, int socket_type); +gboolean gaim_network_listen(unsigned short port, int socket_type, + GaimNetworkListenCallback cb, gpointer cb_data); /** * Opens a listening port selected from a range of ports. The range of @@ -132,8 +139,8 @@ * Otherwise a port is chosen at random by the kernel. * * This opens a listening port. The caller will want to set up a watcher - * of type GAIM_INPUT_READ on the returned fd. It will probably call - * accept in the callback, and then possibly remove the watcher and close + * of type GAIM_INPUT_READ on the fd returned in cb. It will probably call + * accept in the watcher callback, and then possibly remove the watcher and close * the listening socket, and add a new watcher on the new socket accept * returned. * @@ -144,12 +151,16 @@ * arg in prefs. * @param socket_type The type of socket to open for listening. * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP. + * @param cb The callback to be invoked when the port to listen on is available. + * The file descriptor of the listening socket will be specified in + * this callback, or -1 if no socket could be established. + * @param cb_data extra data to be returned when cb is called * - * @return The file descriptor of the listening socket, or -1 if - * no socket could be established. + * @return TRUE if the callback will be invoked, or FALSE if unable to obtain + * a local socket to listen on. */ -int gaim_network_listen_range(unsigned short start, unsigned short end, - int socket_type); +gboolean gaim_network_listen_range(unsigned short start, unsigned short end, + int socket_type, GaimNetworkListenCallback cb, gpointer cb_data); /** * Gets a port number from a file descriptor.