jvr/client/client.cc

78 lines
1.3 KiB
C++

#include <iostream>
#include <vr.h>
#include <fstream>
#include <cstring>
#include <cassert>
using namespace std;
#define TRANSFER_BLK (2048)
#define BLK_SIZE (4096)
int num_block = 0;
bool endd = false;
char block[BLK_SIZE];
void vr_accept(const char *data, size_t len)
{
cout << "[APPLICATION] VR_ACCEPT: " << len << " block " << num_block << endl;
if(len == BLK_SIZE)
{
for(int i = 0; i < len; i++)
{
assert(data[i] == 6);
}
num_block++;
} else
{
if (num_block == TRANSFER_BLK)
{
cout << "SUCCESS!" << endl;
}
else {
cout << "ERROR!" << endl;
}
endd = true;
}
}
int main(int argc, char* argv[])
{
if (argc != 3)
{
cout << "invalid arguments." << endl;
return -1;
}
vr_init(argv[1], stoi(argv[2]));
if (stoi(argv[2]) == 0)
{
memset(block, 6, BLK_SIZE);
for (uint32_t i = 0; i < TRANSFER_BLK; i++)
{
cout << "appending block " << i << endl;
vr_append(block, BLK_SIZE);
}
vr_append(block, 10);
vr_append(block, 10);
}
while(!endd)
{
}
// string each;
// while(!cin.eof())
// {
// cin >> each;
// vr_append(each.c_str(), each.length() + 1);
// }
return 0;
}