Programming API example (HTTP client) struct addrinfo hints, *res; int s; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if (getaddrinfo("www.freebsd.org", "http", &hints, &res) != 0) { exit(1); } for (/*nothing*/; res; res = res->ai_next) { s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (s < 0) continue; if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { close(s); s = -1; continue; } break; } write(s, "GET /\r\n", 7); /* bla bla bla */