// JP opened flex table

Click to See Complete Forum and Search --> : Socket creaed in a thread does not getting connection request in OnAccept


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

csanilkumar
November 12th, 2003, 11:10 PM
I didn't get any answer

bala_research
March 28th, 2005, 11:49 AM
Hi;
I have a similar problem. Have you got a solution for it yet? Please reply at the earliest

Regards
Bala

Andreas Masur
March 28th, 2005, 12:19 PM
[ Moved thread ]

Andreas Masur
March 28th, 2005, 12:21 PM
Well...you are replying to a nearly two years old thread...search the forums (especially this one)...the answer should be there if my memory serves me right...

CodeMaker
November 27th, 2005, 08:30 AM
Maybe you can construct the Socket class in the public segment so as to receive the client socket. Use mdsn,you will find that if the socket object goes out of its socpe , will close the current connetion between C and S.

//JP added flex table