资 源 简 介
trying to port java mina http://mina.apache.org to c++.
It will be very simple to create network server or client program like this:
```
class MyPackageFilter
{
public:
int operator ()( char * pData, int len)
{
// printf ("my filter processed
");
if (len >=2 )
{
return 2;
}
return -1;
}
};
class MyHandler : public TcpHandler
{
public:
virtual void message_received(IoSession & session,MessageContext & msg)
{
TcpMessageContext & tcpMsg = (TcpMessageContext &) msg;
char szBuf[1024]= {0};
memcpy(szBuf,tcpMsg.valid_data(), tcpMsg.valid_length());
printf("received data %s , length %d
", szBuf, tcpMsg.valid_length());
}
};
int main(int, char *[])
{
MyHandler tcpHandler;
TcpAcceptorConfigPtr config(new TcpAcceptorConfig());
config->set_tcp_package_parser();
IoAcceptor * pAcceptor = new TcpAcceptor<>(config,tcpHandler);
pAc