GearBite

Dev and other stuff

A short guide to get rid of IPv4 autoconfiguration (successfully tested on Windows Server 2008 R2):

  1. Add IP and Hostname to hosts-file (%WINDIR%\System32\drivers\etc)
  2. In CMD enter: netsh interface ipv4 show inter
  3. Note the index number of the ethernet adapter
  4. In CMD enter (## = Index number you noted): netsh interface ipv4 set interface ## dadtransmits=0 store=persistent
  5. Stop and disable DHCP-Client service
  6. Reboot
  7. Enable and start DHCP-Client service

Original Source: http://www.techsupportforum.com/forums/f31/solved-autoconfiguration-ipv4-address-500847.html#post4283601

February 24th, 2014

Posted In: Windows

Tags: , , ,

Leave a Comment

Tired of creating sockets for each protocol, to make your application listen on all addresses for a given port ?

There is no more pain. Here is a cool new feature supported since Vista and Windows Server Longhorn. By just setting a socketoption, you will be able to use the same socket to accept connections from both ipv4 and ipv6 clients.

The following sample code shows how to configure the server socket.

static void Main(string[] args)
{
    Socket sock = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
    sock.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);
    sock.Bind(new IPEndPoint(IPAddress.IPv6Any, 8000));
    sock.Listen(4);
    Socket client = sock.Accept();
    Console.WriteLine("Client has connected successfully with the server");
}

Create an IPv6 socket. Set the socket option IPV6_V6Only to false (by default it is true), to enable the socket to accept connections from ipv4 addresses too. Bind and Listen as usual. Now both ipv4 and ipv6 clients can connect to it.
More info can be found in http://www.ietf.org/rfc/rfc3493.txt.

This is because Vista has a completely redesigned TCP/IP stack.

Whereas Windows XP and Win2k3 have a dual stack architecture, i.e., the Tcp, Udp layer is separate for both ipv4 and ipv6 protocols, Vista supports the dual IP layer architecture. That is, Only a single Tcp, Udp layer is present for both the ipv4 and ipv6 protocols.

Other features of the next Generation TCP/IP stack supported in Vista can be found at http://www.microsoft.com/technet/community/columns/cableguy/cg0905.mspx

Original Source: Tired of creating sockets for each protocol

February 19th, 2014

Posted In: .Net

Tags: , , , , ,

Leave a Comment