diff --git a/network/connection.c b/network/connection.c index 057fbba..9d09e83 100644 --- a/network/connection.c +++ b/network/connection.c @@ -109,6 +109,7 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond, int sk; DBusMessage *reply; const char *pdev; + struct timeval t = { 0, 0 }; if (cond & G_IO_NVAL) return FALSE; @@ -155,6 +156,8 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond, sk = g_io_channel_unix_get_fd(chan); + setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(t)); + if (bnep_connadd(sk, BNEP_SVC_PANU, nc->dev)) { error("%s could not be added", nc->dev); goto failed; @@ -196,6 +199,7 @@ static int bnep_connect(struct network_conn *nc) unsigned char pkt[BNEP_MTU]; GIOChannel *io; int err = 0; + struct timeval t = { 30, 0 }; /* Send request */ req = (void *) pkt; @@ -206,6 +210,8 @@ static int bnep_connect(struct network_conn *nc) s->dst = htons(nc->id); s->src = htons(BNEP_SVC_PANU); + setsockopt(nc->sk, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(t)); + io = g_io_channel_unix_new(nc->sk); g_io_channel_set_close_on_unref(io, FALSE);