---
name: "sockaddr"
section: "3type"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sockaddr/3type"
---

# sockaddr(3type)

socket address

## NAME

sockaddr, sockaddr\_storage, socklen\_t - socket address

## LIBRARY

Standard C library (*libc*)

## SYNOPSIS

```
#include <sys/socket.h>
```

**struct sockaddr {**     **sa\_family\_t     sa\_family;**      /\* Address family \*/     **char            sa\_data\[\];**      /\* Socket address \*/ **};**

**struct sockaddr\_storage {**     **sa\_family\_t     ss\_family;**      /\* Address family \*/ **};**

**typedef** /\* ... \*/ **socklen\_t;** **typedef** /\* ... \*/ **sa\_family\_t;**

## DESCRIPTION

- *sockaddr*

  Describes a socket address.

- *sockaddr\_storage*

  A structure at least as large as any other *sockaddr\_*\* address structures. It's aligned so that a pointer to it can be cast as a pointer to other *sockaddr\_*\* structures and used to access its fields.

- *socklen\_t*

  Describes the length of a socket address. This is an integer type of at least 32 bits.

- *sa\_family\_t*

  Describes a socket's protocol family. This is an unsigned integer type.

### Internet domain sockets

See [**sockaddr\_in**(3type)](/sockaddr_in/3type.md) and [**sockaddr\_in6**(3type)](/sockaddr_in6/3type.md).

### UNIX domain sockets

See [**sockaddr\_un**(3type)](/sockaddr_un/3type.md).

## STANDARDS

POSIX.1-2024.

## HISTORY

POSIX.1-2001.

*socklen\_t* was invented by POSIX. See also [**accept**(2)](/accept/2.md).

These structures were invented before modern ISO C strict-aliasing rules. If aliasing rules are applied strictly, these structures would be extremely difficult to use without invoking undefined behavior. POSIX.1-2024 fixed this by requiring that implementations make sure that these structures can be safely used as they were designed.

## NOTES

*socklen\_t* is also defined in *\<netdb.h\>*.

*sa\_family\_t* is also defined in *\<netinet/in.h\>* and *\<sys/un.h\>*.

## SEE ALSO

[**accept**(2)](/accept/2.md), [**bind**(2)](/bind/2.md), [**connect**(2)](/connect/2.md), [**getpeername**(2)](/getpeername/2.md), [**getsockname**(2)](/getsockname/2.md), [**getsockopt**(2)](/getsockopt/2.md), [**sendto**(2)](/sendto/2.md), [**setsockopt**(2)](/setsockopt/2.md), [**socket**(2)](/socket/2.md), [**socketpair**(2)](/socketpair/2.md), [**getaddrinfo**(3)](/getaddrinfo/3.md), [**gethostbyaddr**(3)](/gethostbyaddr/3.md), [**getnameinfo**(3)](/getnameinfo/3.md), [**htonl**(3)](/htonl/3.md), [**ipv6**(7)](/ipv6/7.md), [**socket**(7)](/socket/7.md)
