Server Programming to keep on looking for client connection

Hi I wrote a server Program in C,

Here it is, this is a just socket creation alone,

bool myclass::CreateSocket()
{
    struct sockaddr_in sockaddr_in;
    sockaddr_in.sin_family = AF_INET;
    sockaddr_in.sin_port = 1100;
    sockaddr_in.sin_addr.s_addr = INADDR_ANY;
    mServerSockDesc = socket(AF_INET, SOCK_STREAM, 0);
    if(mServerSockDesc <= 0)
    {
        cout<<" Error: Server Socket Creation Failed - CreateSocket() ";
        return false;
    }
    mBindStatus = bind(mServerSockDesc,(struct sockaddr *) &sockaddr_in,sizeof(sockaddr_in));
    if(mBindStatus == -1)
    {
        cout<<" Error : Server Socket Bind Failed - CreateSocket() ";
        return false;
    }
    mListenStatus = listen(mServerSockDesc,10);
    if(mListenStatus == -1 )
    {
     cout<<" Error : Server Socket Listen Status Failed - CreateSocket() ";
        return false;
    }
    return true;
}

The Problem is, The server is not lisening to client after some time say 2 hour.

my server is running, and few clients are connected. after 2 hour, the client show it as connected, but it is not performing any operation. If i try to reconncet my client, the server is not accepting the client. When i saw the Log file, the server is not at all running.

The server has to Keep on running, it should not stop. At any time means after two days also if i try to connect it has accept my client connection.

Can any one help me in how to achive this?

Use CODE tags when displaying code, data or logs to enhance readability and to preserve formatting like indention etc., ty.

First of all, you are using C++ not C.

To correct you problem you need to add a loop after listen(). i.e.

 /*  Enter an infinite loop to respond to client requests  */
while ( 1 ) {

	/*  Wait for a connection, then accept() it  */
	if ( (connSocket = accept(mServerSockDesc, NULL, NULL) ) < 0 ) {
              /* add error handling here */
	}

        /* do processing here */
        
	/*  Close the connected socket  when finished  */
	if ( close(conn_s) < 0 ) {
               /* add error handling here */
	}
}

Inside the While I'm listening for the New connection. Even though after some point of time, it is not ready to accept the client connection.

Could you rephrase that? I don't think the question translated.

I think the OP meant, even after modifying the code with the suggestion posted, its still not accepting the connection as expected.

Could you please post the modified segment of your code?