Its of course non blocking. Just call INetwork::receive once a frame and it will return all messages received until then.
Download
Example:
Server
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include "INetwork.h"
int main(int argc, char* argv[])
{
AppFrame::INetwork* network = AppFrame::createNetwork("Sudi", 80, 2, 2, "none");
if (network->Error())
return 1;
while(1)
{
AppFrame::array<AppFrame::NetworkPacket*> p = network->receive();
printf("Receive %i packets\n", p.size());
for(AppFrame::u32 i=0;i<p.size();i++)
{
printf("Receiving: %i\n", p[i]->Packet_ID);
p[i]->drop();
}
printf("run\n");
}
printf("done\n");
system("pause");
return 0;
}
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include "INetwork.h"
#include "appArray.h"
int main(int argc, char* argv[])
{
AppFrame::INetwork* network = AppFrame::createNetwork("Sudi", 500, 1, 0, "none");
if (network->Error())
return 1;
if (network->connect2Peer("localhost", 80))
{
printf("connected\n");
}
while(1)
{
AppFrame::array<AppFrame::NetworkPacket*> p = network->receive();
printf("Receive %i packets\n", p.size());
for(AppFrame::u32 i=0;i<p.size();i++)
{
printf("Receiving: %i\n", p[i]->Packet_ID);
p[i]->drop();
}
}
delete network;
printf("done\n");
system("pause");
return 0;
}