[glib/w32-testsuite-fixes-socket: 2/3] socket test: Bind Windows UDP sockets before calling recv()
- From: LRN <ruslanizhb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/w32-testsuite-fixes-socket: 2/3] socket test: Bind Windows UDP sockets before calling recv()
- Date: Wed, 13 Feb 2019 18:27:02 +0000 (UTC)
commit f150de213989639da3f8cfd7d5760ab4060df410
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Mon Feb 11 23:44:55 2019 +0000
socket test: Bind Windows UDP sockets before calling recv()
Winsock can't recv() on unbound UDP sockets. Bind the socket
to loopback before trying to receive data on it.
gio/tests/socket.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/gio/tests/socket.c b/gio/tests/socket.c
index 064202d11..a3f3c43cb 100644
--- a/gio/tests/socket.c
+++ b/gio/tests/socket.c
@@ -829,6 +829,10 @@ test_ip_sync_dgram_timeouts (GSocketFamily family)
GCancellable *cancellable = NULL;
GThread *cancellable_thread = NULL;
gssize len;
+#ifdef G_OS_WIN32
+ GInetAddress *iaddr;
+ GSocketAddress *addr;
+#endif
client = g_socket_new (family,
G_SOCKET_TYPE_DATAGRAM,
@@ -840,6 +844,16 @@ test_ip_sync_dgram_timeouts (GSocketFamily family)
g_assert_cmpint (g_socket_get_socket_type (client), ==, G_SOCKET_TYPE_DATAGRAM);
g_assert_cmpint (g_socket_get_protocol (client), ==, G_SOCKET_PROTOCOL_DEFAULT);
+#ifdef G_OS_WIN32
+ /* Winsock can't recv() on unbound udp socket */
+ iaddr = g_inet_address_new_loopback (family);
+ addr = g_inet_socket_address_new (iaddr, 0);
+ g_object_unref (iaddr);
+ g_socket_bind (client, addr, TRUE, &error);
+ g_object_unref (addr);
+ g_assert_no_error (error);
+#endif
+
/* No overall timeout: test the per-operation timeouts instead. */
g_socket_set_timeout (client, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]