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.