@@ -1664,7 +1664,6 @@ KS_DECLARE(ks_status_t) kws_connect_ex(kws_t **kwsP, ks_json_t *params, kws_flag
1664
1664
const char * ip = "127.0.0.1" ;
1665
1665
ks_port_t port = 443 ;
1666
1666
// char buf[50] = "";
1667
- struct hostent * he ;
1668
1667
const char * url = ks_json_get_object_string (params , "url" , NULL );
1669
1668
// const char *headers = ks_json_get_object_string(params, "headers", NULL);
1670
1669
const char * host = NULL ;
@@ -1673,6 +1672,7 @@ KS_DECLARE(ks_status_t) kws_connect_ex(kws_t **kwsP, ks_json_t *params, kws_flag
1673
1672
char * p = NULL ;
1674
1673
const char * client_data = NULL ;
1675
1674
int destroy_ssl_ctx = 0 ;
1675
+ ks_status_t status ;
1676
1676
1677
1677
if (!url ) {
1678
1678
ks_json_t * tmp ;
@@ -1732,20 +1732,8 @@ KS_DECLARE(ks_status_t) kws_connect_ex(kws_t **kwsP, ks_json_t *params, kws_flag
1732
1732
1733
1733
if (!host || !path ) return KS_STATUS_FAIL ;
1734
1734
1735
- he = gethostbyname (host );
1736
-
1737
- if (!he ) {
1738
- ip = host ;
1739
-
1740
- if (strchr (ip , ':' )) {
1741
- family = AF_INET6 ;
1742
- }
1743
-
1744
- ks_addr_set (& addr , ip , port , family );
1745
- } else {
1746
- ks_addr_set_raw (& addr , he -> h_addr , port , ((struct sockaddr_in * )he -> h_addr )-> sin_family );
1747
- // ip = ks_addr_get_host(&addr1);
1748
- }
1735
+ status = ks_addr_getbyname (host , port , AF_UNSPEC , & addr );
1736
+ if (status != KS_STATUS_SUCCESS ) return status ;
1749
1737
1750
1738
cl_sock = ks_socket_connect_ex (SOCK_STREAM , IPPROTO_TCP , & addr , timeout_ms );
1751
1739
0 commit comments