资 源 简 介
Simple but robust networking library with async UDP sockets support. Underlying implementation uses Boost ASIO library in implementation. Why would I use this and not use Boost ASIO directly? Ease of use. mnet provides greatly simplified async UDP sockets usage.
Working all-in-one client-server (run with "-server" command line argument to run as server):
```
include
const char SERVER_ADDR[] = "localhost:12000";
using namespace mnet;
class Ping : public PacketListener
{
public:
IOService ios;
UDPSocket socket;
Ping( bool is_server ) :
socket( ios, is_server ? Address(ios,SERVER_ADDR) : Address() )
{
if (is_server)
{
socket.addPacketListener( this );
for (;;)
ios.poll();
}
else
{
char msg[128] = "Hello";
socket.send( Address(ios,SERVER_ADDR), msg, strlen(msg)+1 );
}
}
void onPacketReceived( const Address& remote,