-
-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Hi,
I have problem with joining threads.
I tried milions of ideas and solution for example: atomic operation for is_runnning bool in threaded server, checking joinable and many many more. The issue is that after i want finish work threads dont join but they work in loop (i dont know why).
I modified a little tcplinuxserver.cpp to work more like a client (i need p2p connection, so my app need to be client and server at same time) Does anyone has any ideas what i am doing wrong?
here is modified HandleConnection method that work in loop:
void LinuxTcpSocketServer::HandleConnection()
{
StreamReader reader(DEFAULT_BUFFER_SIZE);
string request, response;
reader_port = this->Connect();
std::cout << "LinuxTcpSocketServer::HandleConnection::port:: " << reader_port << std::endl;
reader.Read(request, reader_port, DEFAULT_DELIMITER_CHAR);
std::cout << "LinuxTcpSocketServer::HandleConnection::request" << request << std::endl;
this->ProcessRequest(request, response);
response.append(1, DEFAULT_DELIMITER_CHAR);
StreamWriter writer;
if (!writer.Write(response, reader_port))
{
throw JsonRpcException(Errors::ERROR_SERVER_CONNECTOR, "Could not write request");
}
std::cout << "LinuxTcpSocketServer::HandleConnection::response" << response << std::endl;
//CleanClose(reader_port); // ? powinno zamykac?
close(reader_port);
return;
}
here are logs:
Sorry i am kind a new to threads and dont fully understand how it works.
Thanks for help!