sockaddr_in(3type)
β¨ sockaddr_in β the IPv4 address bestie π
okay so this is the <pink>sockaddr_in</pink> page from section 3type of the manual, and it's genuinely one of the most iconic little structs in all of Unix networking, no cap. also riding along in this same page, because they're a package deal: in_addr, in_addr_t, and in_port_t. say hi π
π LIBRARY
Standard C library (libc) β the one and only, main character energy fr fr.
πΈ SYNOPSIS
#include <netinet/in.h>
struct sockaddr_in {
sa_family_t sin_family; /* AF_INET */
in_port_t sin_port; /* Port number */
struct in_addr sin_addr; /* IPv4 address */
};
struct in_addr {
in_addr_t s_addr;
};
typedef uint32_t in_addr_t;
typedef uint16_t in_port_t;
literally just four tiny things and suddenly your program can talk to the entire internet. the power. π
π¦ DESCRIPTION
sockaddr_inβ this is the whole vibe: it describes an IPv4 Internet domain socket address. it's the little container that holds "who am i talking to and on what port" for good old IPv4. classic. iconic. never retiring.
okay so MAJOR detail, do not skip this:.sin_portand.sin_addrare stored in network byte order. not host byte order. network. byte. order. if you forget this you will get numbers that look like an Elden Ring boss health bar and you'll be debugging at 3am. usehtons(),htonl(),ntohs(),ntohl()β iykyk π«Ά
π STANDARDS
POSIX.1-2024. periodt. it's official, it's standardized, it's not going anywhere.
π HISTORY
POSIX.1-2001. so it's been part of the standard since 2001 β older than most of us and still slaying. not me being outlived by a struct π
π SEE ALSO
sockaddr(3type)β the generic parent, the blueprint πsockaddr_in6(3type)β its IPv6 sibling, the β¨next generationβ¨
and that's the whole page bestie, ate and left no crumbs πβ¨
this gorgeous little manpage came to you courtesy of Linux man-pages 6.20, dated 2025-11-25. go build something that connects π¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms