sockaddr

Contains socket address information.

Service:Networking

Syntax

  #include <sys/socket.h>
  
  struct sockaddr 
  {
     sa_family_t   sa_family; 
     char          sa_data[14]; 
  };
  

Fields

sa_family

Specifies the address family.

sa_data

Specifies the direct address (maximum of 14 bytes).

Remarks

The sockaddr structure is used for TCP over IP sockets. The length of the socket structure is fixed at 16 bytes.

Typically, a client program uses zeros for both fields. This ensures that the client program is unique for each session of the network application running with the same server. Normally, a server specifies only the port.

For IPv4, use the sockaddr_in structure to specify the address by combining the fields: sin_port+sin_addr+sin_zero.

For IPv6, use the sockaddr_in6 structure to specify the address.