Advertisement

::OnAccept() callback...

Started by December 24, 1999 02:09 PM
5 comments, last by GameDev.net 24 years, 11 months ago
Yeah I have. The client says its connected properly too. So I'm at a loss to know whats the problem.

Cheers,

leroy.

Yeah I do, I've checked the source to CSocket::OnAccept() as well, nothing there, so not calling it isn't a problem.

This is really bugging me (no pun intended), everything was going fine till I hit this.

Cheers,

leroy.

Advertisement
That code you sent didn't work either. I'm guessing it must be something to do with my program being a windows console program.

Cheers,

leroy.

Yeah, that's probably the problem. CSocket requires the MFC message loop. Correct me if I'm wrong.
Hrm, well I selected MFC support for the console application in the App wizard, and included afxsock.h as well as calling AfxSocketInit() in the init code.

So I'm stumped. The solution? Recoded the thing as a Windowed application. Not really a good solution, but it'll do for the moment.

Cheers,

leroy.

I'm in the middle of coding a server for a game being developed. The server is a windows console application using MFC.

The problem I has is this...

I have a class called SSCSocket which is derived from the CSocket class, now I've created an overide for the OnAccept() virtual function.

When trying this out though, the OnAccept() function is never executed.

Here's some code...

class SSCSocket : public CSocket
{
public:
SSCSocket();
virtual ~SSCSocket();
public:
virtual void OnAccept(int nErrorCode);
virtual void OnClose(int nErrorCode);

};

Is declared in the header, and here's the implementation

void SSCSocket::OnAccept(int nErrorCode)
{
HandleNewClient();
}

HandleNewClient() is a global function I use to accept the socket and create things.

Shouldn't OnAccept() be called when a connection is sitting in the queue, waiting to be accepted? Or do I need to do something else?

Cheers,

leroy.

Advertisement
If you want to code the server as a Windows Console I would drop the MFC sockets and code your own socket code.
You will need to create your socket non-blocking and assosciate it with a network event ( WSACreateEvent(), WSAEventSelect() ).
If you have any questions on how to do this just send me an email.

------------------
David "Dak Lozar" Loeser
bcs@iglou.com

Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous

This topic is closed to new replies.

Advertisement