csanilkumar
November 10th, 2003, 12:15 AM
I have simple client server program using sockets. I have derived a class from CSocket and overrided the OnAccept() handler. There I am creating a new static Socket class for communication. As follows
static MySocket sktConnection;
if(!nErrorCode)
{
if(Accept(sktConnection))
MessageBox(NULL,"Connection request accepted","Error",MB_OK);
else
MessageBox(NULL,"Connection request not accepted","Error",MB_OK);
}
In the server application, the server socket is created in a thread (dynamically). It then listens for connections
thread function is as follows
{
MySocket* pServer=new MySocket;
if(!pServer)
return 0;
if (!pServer->Create(4560))
{
AfxMessageBox("Create Server socket failed");
return 0;
}
if(!pServer->Listen())
{
AfxMessageBox("Listening failed");
return 0;
}
while (CSocketServerDlg::bContinue)
{
Beep( 1000, 100 );
Sleep(1000);
}
pServer->Close();
delete pServer;
}
Using a client program I am connecting to the server. The client program connects to the server, but the server is not getting the connection request in the OnAccept() handler. This is my problem.
Please help
static MySocket sktConnection;
if(!nErrorCode)
{
if(Accept(sktConnection))
MessageBox(NULL,"Connection request accepted","Error",MB_OK);
else
MessageBox(NULL,"Connection request not accepted","Error",MB_OK);
}
In the server application, the server socket is created in a thread (dynamically). It then listens for connections
thread function is as follows
{
MySocket* pServer=new MySocket;
if(!pServer)
return 0;
if (!pServer->Create(4560))
{
AfxMessageBox("Create Server socket failed");
return 0;
}
if(!pServer->Listen())
{
AfxMessageBox("Listening failed");
return 0;
}
while (CSocketServerDlg::bContinue)
{
Beep( 1000, 100 );
Sleep(1000);
}
pServer->Close();
delete pServer;
}
Using a client program I am connecting to the server. The client program connects to the server, but the server is not getting the connection request in the OnAccept() handler. This is my problem.
Please help