mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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.
This commit is contained in:
parent
1f5d7eeaa7
commit
f150de2139
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user