struct addrinfo hints, *res;
// 首先,使用 getaddrinfo() 載入位址結構:
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // 使用 IPv4 或 IPv6,兩者皆可
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE; // 幫我填上我的 IP
getaddrinfo(NULL, "3490", &hints, &res);
sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
// 將它綁定到我們於 getaddrinfo() 中傳遞的 port:
bind(sockfd, res->ai_addr, res->ai_addrlen);
listen(sockfd, 10); // 將 s 設定為 server(監聽的)的 socket
// 接著這裡會有個迴圈用來呼叫 accept() 接受連線