static void Main(string args)
int port = 11000;
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipendpoint = new IPEndPoint(IPAddress.Any, port);
Console.WriteLine("Successfully bound to port " + port);
catch (SocketException e)
Console.WriteLine("Winsock error: " + e.ErrorCode.ToString() + ", " + e.Message.ToString());
I get the error code [b]10022[/b] when trying to bind the UDP socket, which is "Invalid argument specified". This is the same for all the UDP server examples on the internet at the binding stage, as well as the MSDN one. It will work if the port
is 0, but not if the port is anything but 0. TCP binding works fine, and I can make a UDP server on any port with Java (the binding works fine) but in C# it gives me this error.
The code works for everyone I've asked to try it, and I've got the latest NET framework (version 4) and Windows XP with SP3 so I know the commands are supported by the OS (also, Visual C# 2010 Express and 2008 Express both give this error).
Any ideas to fix it?
View Complete Post