Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

::OnAccept() callback...

Recommended Posts

Guest Anonymous Poster
Yeah I have. The client says its connected properly too. So I'm at a loss to know whats the problem.

Cheers,

leroy.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites