Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
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
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 ("127.0.0.1");
int ret = connect (sock, (struct sockaddr*)&saddr, sizeof (saddr));
printf ("CONNECT: %d - %s\n", ret, strerror (errno));
I'll change the test to use 127.0.0.1 and port 53.