try
{
u16 peer_id;
- u8 data[100];
+ SharedBuffer<u8> data;
infostream<<"** running client.Receive()"<<std::endl;
- u32 size = client.Receive(peer_id, data, 100);
+ u32 size = client.Receive(peer_id, data);
infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
try
{
u16 peer_id;
- u8 data[100];
+ SharedBuffer<u8> data;
infostream<<"** running server.Receive()"<<std::endl;
- u32 size = server.Receive(peer_id, data, 100);
+ u32 size = server.Receive(peer_id, data);
infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
try
{
u16 peer_id;
- u8 data[100];
+ SharedBuffer<u8> data;
infostream<<"** running client.Receive()"<<std::endl;
- u32 size = client.Receive(peer_id, data, 100);
+ u32 size = client.Receive(peer_id, data);
infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
try
{
u16 peer_id;
- u8 data[100];
+ SharedBuffer<u8> data;
infostream<<"** running server.Receive()"<<std::endl;
- u32 size = server.Receive(peer_id, data, 100);
+ u32 size = server.Receive(peer_id, data);
infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
sleep_ms(50);
u16 peer_id;
- u8 recvdata[100];
+ SharedBuffer<u8> recvdata;
infostream<<"** running server.Receive()"<<std::endl;
- u32 size = server.Receive(peer_id, recvdata, 100);
+ u32 size = server.Receive(peer_id, recvdata);
infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<", data="<<*data
<<std::endl;
- assert(memcmp(*data, recvdata, data.getSize()) == 0);
+ assert(memcmp(*data, *recvdata, data.getSize()) == 0);
}
#endif
u16 peer_id_client = 2;
infostream<<"*** Receiving the packets"<<std::endl;
u16 peer_id;
- u8 recvdata[20];
+ SharedBuffer<u8> recvdata;
u32 size;
infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
- size = client.Receive(peer_id, recvdata, 20);
+ size = client.Receive(peer_id, recvdata);
infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
- <<", data="<<recvdata
+ <<", data="<<*recvdata
<<std::endl;
assert(size == data1.getSize());
- assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
+ assert(memcmp(*data1, *recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER);
infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
- size = client.Receive(peer_id, recvdata, 20);
+ size = client.Receive(peer_id, recvdata);
infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
- <<", data="<<recvdata
+ <<", data="<<*recvdata
<<std::endl;
assert(size == data2.getSize());
- assert(memcmp(*data2, recvdata, data2.getSize()) == 0);
+ assert(memcmp(*data2, *recvdata, data2.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER);
bool got_exception = false;
{
infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
- size = client.Receive(peer_id, recvdata, 20);
+ size = client.Receive(peer_id, recvdata);
infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
- <<", data="<<recvdata
+ <<", data="<<*recvdata
<<std::endl;
}
catch(con::NoIncomingDataException &e)
//int receivetimes = myrand_range(1,20);
int receivetimes = 20;
for(int i=0; i<receivetimes; i++){
- u8 recvdata[100000];
+ SharedBuffer<u8> recvdata;
u16 peer_id = 132;
u16 size = 0;
bool received = false;
try{
- size = client.Receive(peer_id, recvdata, 100000);
+ size = client.Receive(peer_id, recvdata);
received = true;
}catch(con::NoIncomingDataException &e){
}
sleep_ms(3000);
- u8 recvdata[datasize + 1000];
+ SharedBuffer<u8> recvdata;
infostream<<"** running client.Receive()"<<std::endl;
u16 peer_id = 132;
u16 size = 0;
if(porting::getTimeMs() - timems0 > 5000)
break;
try{
- size = client.Receive(peer_id, recvdata, datasize + 1000);
+ size = client.Receive(peer_id, recvdata);
received = true;
}catch(con::NoIncomingDataException &e){
}
infostream<<"Received data (size="<<size<<"):";
for(int i=0; i<size && i<20; i++){
if(i%2==0) DEBUGPRINT(" ");
- DEBUGPRINT("%.2X", ((int)((const char*)recvdata)[i])&0xff);
+ DEBUGPRINT("%.2X", ((int)(recvdata[i]))&0xff);
}
if(size>20)
infostream<<"...";
infostream<<std::endl;
- assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
+ assert(memcmp(*data1, *recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER);
}