38 struct addrinfo hints = { 0 }, *ai, *cur_ai;
41 int listen_socket = 0;
45 int timeout = 100, listen_timeout = -1;
46 char hostname[1024],proto[1024],path[1024];
50 &port, path,
sizeof(path), uri);
51 if (strcmp(proto,
"tcp"))
53 if (port <= 0 || port >= 65536) {
62 timeout = strtol(buf,
NULL, 10);
65 listen_timeout = strtol(buf,
NULL, 10);
70 snprintf(portstr,
sizeof(portstr),
"%d", port);
79 "Failed to resolve hostname %s: %s\n",
97 listen_timeout, h)) < 0) {
103 timeout * 100, h, !!cur_ai->ai_next)) < 0) {
118 if (cur_ai->ai_next) {
120 cur_ai = cur_ai->ai_next;
143 ret = recv(s->
fd, buf, size, 0);
157 ret = send(s->
fd, buf, size, 0);
174 return shutdown(s->
fd, how);