FS-10167: Fixed sockets in libks, testsock now runs correctly under windows
This commit is contained in:
parent
ad968eda6f
commit
be451e4305
|
@ -74,6 +74,13 @@ KS_DECLARE(ks_status_t) ks_init(void)
|
|||
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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
|
||||
x = read((int)cl_sock, buf, sizeof(buf));
|
||||
printf("TCP CLIENT READ %d bytes [%s]\n", x, buf);
|
||||
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:
|
||||
|
||||
|
|
Loading…
Reference in New Issue