diff --git a/libs/libks/src/ks.c b/libs/libks/src/ks.c index ee9db3dfbe..499e2ff118 100644 --- a/libs/libks/src/ks.c +++ b/libs/libks/src/ks.c @@ -73,7 +73,14 @@ KS_DECLARE(ks_status_t) ks_init(void) ks_ssl_init_ssl_locks(); ks_global_pool(); ks_rng_init(); - + +#ifdef __WINDOWS__ + WSADATA wsaData; + WORD wVersionRequested = MAKEWORD(2, 2); + + WSAStartup(wVersionRequested, &wsaData); +#endif + return KS_STATUS_SUCCESS; } @@ -81,6 +88,10 @@ KS_DECLARE(ks_status_t) ks_shutdown(void) { ks_status_t status = KS_STATUS_SUCCESS; +#ifdef __WINDOWS__ + WSACleanup(); +#endif + ks_ssl_destroy_ssl_locks(); //ks_rng_shutdown(); diff --git a/libs/libks/test/testsock.c b/libs/libks/test/testsock.c index f825768b70..e17b9b6c50 100644 --- a/libs/libks/test/testsock.c +++ b/libs/libks/test/testsock.c @@ -180,15 +180,21 @@ static int test_tcp(char *ip) ks_addr_set(&addr, ip, tcp_port, family); cl_sock = ks_socket_connect(SOCK_STREAM, IPPROTO_TCP, &addr); - int x; + //int x; printf("TCP CLIENT SOCKET %d %s %d\n", (int)cl_sock, addr.host, addr.port); - x = write((int)cl_sock, __MSG, (unsigned)strlen(__MSG)); - printf("TCP CLIENT WRITE %d bytes\n", x); - - x = read((int)cl_sock, buf, sizeof(buf)); - printf("TCP CLIENT READ %d bytes [%s]\n", x, buf); + ks_size_t msglen = strlen(__MSG); + ks_socket_send(cl_sock, __MSG, &msglen); + printf("TCP CLIENT WRITE %d bytes\n", (int)msglen); + //x = write((int)cl_sock, __MSG, (unsigned)strlen(__MSG)); + //printf("TCP CLIENT WRITE %d bytes\n", x); + + msglen = sizeof(buf); + ks_socket_recv(cl_sock, buf, &msglen); + printf("TCP CLIENT READ %d bytes [%s]\n", (int)msglen, buf); + //x = read((int)cl_sock, buf, sizeof(buf)); + //printf("TCP CLIENT READ %d bytes [%s]\n", x, buf); end: