Bug 5503 - Test System.Net.Sockets.UdpClientTest.Constructor6 fail
Summary: Test System.Net.Sockets.UdpClientTest.Constructor6 fail
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2012-06-03 23:16 UTC by Vinicius Jarina
Modified: 2012-06-26 20:10 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Vinicius Jarina 2012-06-03 23:16:35 UTC
System.Net.Sockets.SocketException : The requested address is not valid in this context
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00152] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1267
at System.Net.Sockets.UdpClient.DoConnect (System.Net.IPEndPoint endPoint) [0x00000] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/class/System/System.Net.Sockets/UdpClient.cs:144
Comment 1 Martin Baulig 2012-06-26 20:06:21 UTC
There are two problems in this test:

a) "localhost" may resolve to either IPv4 or IPv6; Windows seem to prefer IPv6.

b) Neither Linux (3.2.0 kernel running Ubuntu) nor Mac OS Lion accept sending to
    UDP port 0 when used with UdpClient.Send().  Windows does.  Using Connect() on
    that port followed by Send() works on Ubuntu, though.

I tested this with a small C program and port 0 is actually invalid on Mac OS.

	int sock = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	printf ("SOCKET: %d\n", sock);

	struct sockaddr_in saddr;
	memset (&saddr, 0, sizeof (saddr));
	saddr.sin_family = PF_INET;
	saddr.sin_port = htons (0);
	saddr.sin_addr.s_addr = inet_addr ("");
	int ret = connect (sock, (struct sockaddr*)&saddr, sizeof (saddr));
	printf ("CONNECT: %d - %s\n", ret, strerror (errno));

I'll change the test to use and port 53.