I have written small Server app which accepts connections from clients. But what I notice is when the server gets idle for a long time, Clients can not connect meaning Server PORT is down even the process is still running. I made a NETSTAT on the PORT but no results prompted meaning PORT is down.
// -------------------------------------------------------------------
// Simulate server accept method and fork
// new process for each client
// -------------------------------------------------------------------
int ServerSocket::acceptConnections()
{
clilen = sizeof(cliaddr);
//cout << "Accepting connections" << endl;
//FrameworkManager::printMsg("Accepting connections");
PRINT_MESSAGE_TIME("INFO ", "Accepting connections");
// Get the IP of the client
struct sockaddr_in newClientAddr;
int addrSize = sizeof(newClientAddr);
getpeername(connfd, (struct sockaddr *) &newClientAddr, (socklen_t *)&addrSize);