Domanda
Sto cercando di creare un piccolo server HTTP in C# ma ho qualche problema con i client IPv6.Ho il supporto IPv6 sulla mia macchina ma quando provo a creare un socket di ascolto fallisce.
Log("Creating server socket on port {0}", LogType.Info, _port);
_serversocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
_serversocket.Bind(new IPEndPoint(IPAddress.Any, _port));
_serversocket.Listen(10);
Cosa sto facendo di sbagliato qui?
Il codice lancia questa eccezione:Il sistema ha rilevato un indirizzo del puntatore non valido nel tentativo di utilizzare un argomento del puntatore in una chiamata
MODIFICARE:
Traccia dello stack:
su system.net.sockets.socket.dobind (endpoint endpointsNapShot, SocketAddress SocketAddress) su system.net.sockets.socket.bind (endpoint localEP) su troutserver.trout.start (porta INT32) in C: Users Chris Documents Documents Visual Studio 2008 Projects Troutserver Trout Trout.cs: riga 62
Il tipo è SocketException
Soluzione
Tentativo:
new IPEndPoint(IPAddress.IPv6Any, _port)