Jump to content

  • Log In with Google      Sign In   
  • Create Account


::OnAccept() callback...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 24 December 1999 - 08:09 AM

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.


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 11 December 1999 - 05:08 AM

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

Cheers,

leroy.


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 11 December 1999 - 10:47 PM

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.


#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 12 December 1999 - 07:10 PM

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.


#5 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 12 December 1999 - 10:21 PM

Yeah, that's probably the problem. CSocket requires the MFC message loop. Correct me if I'm wrong.


#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 13 December 1999 - 12:55 AM

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.


#7 Dak Lozar   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 December 1999 - 08:09 AM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS