Hiho,
I want to make a simple example with CAsyncSocket Obeject. Just a simple Server which accepts a client und disconnect them. By I dont get it work.
I wrote this little class
Header
Code:
#pragma once
//standard
#include <list>
#include <iostream>
//os
#include <afxsock.h>
//projekt
#include <EthernalCraft/McClientConnection.h>
class McManager : public CAsyncSocket
{
public:
McManager();
~McManager();
void Init(unsigned localPort, char* remoteHost, unsigned remotePort);
//event notification
virtual void OnAccept(int nErrorCode);
private:
unsigned localPort;
unsigned remotePort;
char* remoteHost;
std::list<McClientConnection*> connectionList;
};
Source
Code:
# include <EthernalCraft/McManager.h>
McManager::McManager()
{
}
McManager::~McManager()
{
}
void McManager::Init(unsigned int localPort, char *remoteHost, unsigned int remotePort)
{
this->localPort = localPort;
this->remotePort = remotePort;
this->remoteHost = strdup(remoteHost);
if(!Create(
localPort,
SOCK_STREAM,
FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT
))
{
std::cout << "CAsyncSocket::Create failed" << std::endl;
}
if(!Listen())
{
std::cout << "CAsyncSocket::Listen failed" << std::endl;
}
}
void McManager::OnAccept(int nErrorCode)
{
AfxMessageBox("OnAccept");
}
I just want that my OnAccept Method is called, but it wont work and i downt know why
greetings
chrisliebaer