简体   繁体   中英

C# IPv6 Server error

I'm trying to create a small HTTP server in C# but I'm having some trouble with IPv6 clients. I have IPv6 support on my machine but when I try to create a listening socket it fails.

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);

What am I doing wrong here?

The code throws this exception: The system detected an invalid pointer address in attempting to use a pointer argument in a call

EDIT:

Stack Trace:

at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at TroutServer.Trout.Start(Int32 port) in C:\\Users\\Chris\\Documents\\Visual Studio 2008\\Projects\\TroutServer\\trout\\trout.cs:line 62

Type is SocketException

尝试:

new IPEndPoint(IPAddress.IPv6Any, _port)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM