Hi Lichtso. ;-)
I wanted to ask you about the possibility that SocketManager::listed return a exit status code, or at least, a boolean with true or false if the timeout has expired or not.
I thought about this proposal while I tried to solve the next problem;
I am working with the LEGO MindStorms EV3 bricks and the official firmware. In this case I only 'control' one side of the connection [Would this reason be the cause of the problem?]. I am using raw data.
In this context I have detected an anomaly with "SocketManager::listen". The socket is a TCP_CLIENT.
The "listen" does not "wait", and it does not invoke an event ( onReceiveRaw, onStatusChange)
Neither throw an exception away. I am without clues. :-(
In order to get more details perhaps i need debug the netlink library for my very specific use case. :-/ Perhaps later on I make it. However i can not use breakpoints why the problem disappears.
The "workaround" most simple i have found for my problem is to add an active wait BEFORE the SocketManager::listen
std::size_t recibirTimeOut(std::shared_ptr<netLink::Socket> psocket, char *m_recepcion, const std::size_t tamanomaximorecepcion)
{
std::size_t recibidotcp = 0;
netLink::SocketManager socketManager;
socketManager.sockets.insert(psocket); //<-is this legal? it works but...
socketManager.onReceiveRaw = [m_recepcion, &recibidotcp, tamanomaximorecepcion](netLink::SocketManager* manager, std::shared_ptr<netLink::Socket> socket)
{
recibidotcp = socket->sgetn(m_recepcion, tamanomaximorecepcion);
};
//A -one second- active wait ... Why?
std::chrono::high_resolution_clock::time_point end, start;
std::chrono::seconds ms;
start = std::chrono::high_resolution_clock::now();
do
{
end = std::chrono::high_resolution_clock::now();
ms = std::chrono::duration_cast<std::chrono::seconds>(end - start);
}
while (ms.count() < 1);
//end of active wait
socketManager.listen(5.0);
return recibidotcp;
}
bug