GSocket: add support for timeouts

Also add options for testing timeouts to socket test programs

https://bugzilla.gnome.org/show_bug.cgi?id=587898
This commit is contained in:
Dan Winship
2009-12-31 10:29:23 -05:00
parent 2c4a79c810
commit 29f3e3f766
6 changed files with 200 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ gboolean non_blocking = FALSE;
gboolean use_udp = FALSE;
gboolean use_source = FALSE;
int cancel_timeout = 0;
int read_timeout = 0;
gboolean unix_socket = FALSE;
static GOptionEntry cmd_entries[] = {
@@ -31,6 +32,8 @@ static GOptionEntry cmd_entries[] = {
{"unix", 'U', 0, G_OPTION_ARG_NONE, &unix_socket,
"Use a unix socket instead of IP", NULL},
#endif
{"timeout", 't', 0, G_OPTION_ARG_INT, &read_timeout,
"Time out reads after the specified number of seconds", NULL},
{NULL}
};
@@ -151,6 +154,9 @@ main (int argc,
return 1;
}
if (read_timeout)
g_socket_set_timeout (socket, read_timeout);
if (unix_socket)
{
GSocketAddress *addr;