Socket Programming

Articles about socket programming and networking

The new structure to map a IPv6 address is sockaddr_in6. This structure is basically compatible to the generic address structure sockaddr. But make sure you are using sizeof(sockaddr_in6) for any manipulations on the IPv6 structure, because its size changed!!!


struct sockaddr_in6 AddressIPv6;
struct sockaddr& Address = (struct sockaddr&)AddressIPv6;
int iSockedFD = 0;
...          
if (::connect(iSockedFD, 
              &Address, 
              sizeof(AddressIPv6)) >= 0)
{
}

Its safer to use the sockaddr structure only for casting, to pass the address to the socket API functions:


struct sockaddr_in6 AddressIPv6;
struct sockaddr& Address = 
  (struct sockaddr&)AddressIPv6;

int iSockedFD = 0;
...          
if (::connect(iSockedFD, 
             (struct sockaddr*)&AddressIPv6, 
             sizeof(AddressIPv6)) >= 0)
{
}

Following pages helped out and have further informations: