Fix HTTP request creation and simple client example

This commit is contained in:
2025-11-23 23:27:08 +01:00
parent 3c0aecb5f0
commit f6b2c805c6
4 changed files with 41 additions and 11 deletions
+8 -1
View File
@@ -335,7 +335,12 @@ static void socket_update(Socket *s)
continue;
}
}
AddressAndPort addr = s->addrs[s->next_addr];
AddressAndPort addr;
if (s->num_addr == 1)
addr = s->addr;
else
addr = s->addrs[s->next_addr];
int family = (addr.is_ipv4 ? AF_INET : AF_INET6);
NATIVE_SOCKET sock = socket(family, SOCK_STREAM, 0);
@@ -1011,6 +1016,8 @@ int socket_connect(SocketManager *sm, int num_targets,
s->client_secure_context = &sm->client_secure_context;
#endif
sm->num_used++;
socket_update(s);
return 0;
}