client: always set port even if sockfd already created
This commit is contained in:
parent
8ccc64679f
commit
75bbb3b2c0
1 changed files with 8 additions and 8 deletions
|
@ -213,15 +213,11 @@ lws_client_connect_2(struct lws *wsi)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LWS_USE_IPV6
|
#ifdef LWS_USE_IPV6
|
||||||
if (wsi->ipv6) {
|
if (wsi->ipv6)
|
||||||
sa46.sa6.sin6_port = htons(port);
|
|
||||||
wsi->desc.sockfd = socket(AF_INET6, SOCK_STREAM, 0);
|
wsi->desc.sockfd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
} else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
sa46.sa4.sin_port = htons(port);
|
|
||||||
wsi->desc.sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
wsi->desc.sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
}
|
|
||||||
|
|
||||||
if (!lws_socket_is_valid(wsi->desc.sockfd)) {
|
if (!lws_socket_is_valid(wsi->desc.sockfd)) {
|
||||||
lwsl_warn("Unable to open socket\n");
|
lwsl_warn("Unable to open socket\n");
|
||||||
|
@ -276,11 +272,15 @@ lws_client_connect_2(struct lws *wsi)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LWS_USE_IPV6
|
#ifdef LWS_USE_IPV6
|
||||||
if (wsi->ipv6)
|
if (wsi->ipv6) {
|
||||||
|
sa46.sa6.sin6_port = htons(port);
|
||||||
n = sizeof(struct sockaddr_in6);
|
n = sizeof(struct sockaddr_in6);
|
||||||
else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
sa46.sa4.sin_port = htons(port);
|
||||||
n = sizeof(struct sockaddr);
|
n = sizeof(struct sockaddr);
|
||||||
|
}
|
||||||
|
|
||||||
if (connect(wsi->desc.sockfd, (const struct sockaddr *)&sa46, n) == -1 ||
|
if (connect(wsi->desc.sockfd, (const struct sockaddr *)&sa46, n) == -1 ||
|
||||||
LWS_ERRNO == LWS_EISCONN) {
|
LWS_ERRNO == LWS_EISCONN) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue