SOCKADDR_STORAGE (Compact 2013)

3/26/2014

This structure stores socket address information. Because this structure is large enough to store IPv4 or IPv6 address information, its use promotes protocol-family and protocol-version independence, and simplifies cross-platform development. Use this structure in place of the sockaddr structure.

Syntax

typedef struct sockaddr_storage {
  short ss_family;
  char __ss_pad1[_SS_PAD1SIZE];
  __int64 __ss_align;
  char __ss_pad2[_SS_PAD2SIZE];
} SOCKADDR_STORAGE, *PSOCKADDR_STORAGE;

Members

  • ss_family
    Address family of the socket, such as AF_INET.
  • __ ss_pad1
    Reserved. Defined as a 48-bit pad that ensures this structure achieves 64-bit alignment.
  • __ ss_ align
    Reserved. Used by the compiler to align the structure.
  • __ ss_pad2
    Reserved. Used by the compiler to align the structure.

Remarks

Application developers should use only the ss_family member of this structure. The remaining three members ensure the structure is padded appropriately to achieve 64-bit alignment. Such alignment enables protocol-specific socket address data structures to access fields within a SOCKADDR_STORAGE structure without alignment problems. Because of its padding, the structure is 128 bytes in length.

The member field of this structure is isomorphic with the sockaddr structure to enable simplified transition from sockaddr to SOCKADDR_STORAGE.

Requirements

Header

winsock2.h

See Also

Reference

Winsock Structures
sockaddr