diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp index 2f2dad4..aa27589 100644 --- a/src/tcp_socket.cpp +++ b/src/tcp_socket.cpp @@ -126,8 +126,8 @@ client::client(const string address, const ushort port, const uint timeout, SSL_ } struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout*1000; + tv.tv_sec = timeout/1000; + tv.tv_usec = (timeout%1000)*1000; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval))) { throw string("[ERROR] Unable to set timeout "); @@ -206,7 +206,7 @@ string client::obey (size_t byte_limit) { read(sock , res, byte_limit); } - return (string) res; + return string(res); } /** @@ -226,8 +226,8 @@ comming::comming(const server *_srv, const uint timeout, SSL_CTX* securefds) { } struct timeval tv; - tv.tv_sec = 0; // za sad 2 sekunde timeout, harkodirano - tv.tv_usec = timeout*1000; + tv.tv_sec = timeout/1000; + tv.tv_usec = (timeout%1000)*1000; if (setsockopt(conn, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval))) { throw string("[ERROR] Unable to set timeout "); @@ -313,5 +313,5 @@ string comming::obey (size_t byte_limit) { read(conn , res, byte_limit); } - return (string) res; + return string(res); } diff --git a/test/client.cpp b/test/client.cpp index a026c56..0a46f6b 100644 --- a/test/client.cpp +++ b/test/client.cpp @@ -11,7 +11,7 @@ int main() { secure crypto; cout << "init cert " << endl; - client myserver("127.0.0.1", 5000, 500, crypto.fds); + client myserver("127.0.0.1", 5000, 5000, crypto.fds); // client myserver("localhost", 5000); cout << "init client " << endl; diff --git a/test/client.o b/test/client.o index 788827d..c6d1ffe 100755 Binary files a/test/client.o and b/test/client.o differ diff --git a/test/server.cpp b/test/server.cpp index 1a0e44f..93efd37 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -18,7 +18,8 @@ int main() { string fromclient = myclient.obey(); cout << "tell client " << fromclient << endl; - // sleep(5); + // usleep(600*1000); + sleep(5); myclient.tell(fromclient); // myclient.~comming(); diff --git a/test/server.o b/test/server.o index b4ab8be..a5392e9 100755 Binary files a/test/server.o and b/test/server.o differ