本文整理汇总了C++中TestClient::sendBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ TestClient::sendBytes方法的具体用法?C++ TestClient::sendBytes怎么用?C++ TestClient::sendBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestClient
的用法示例。
在下文中一共展示了TestClient::sendBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
TEST(SocketSuite, read)
{
const int port = TEST_PORT_BASE;
char ipAddr[] = "127.0.0.1";
TestClient client;
TestServer server;
ByteArray send, recv;
shared_int DATA = 99;
shared_int TWO_INTS = 2 * sizeof(shared_int);
shared_int ONE_INTS = 1 * sizeof(shared_int);
// Construct server
ASSERT_TRUE(server.init(port));
// Construct a client
ASSERT_TRUE(client.init(&ipAddr[0], port));
pthread_t serverConnectThrd;
pthread_create(&serverConnectThrd, NULL, connectServerFunc, &server);
ASSERT_TRUE(client.makeConnect());
pthread_join(serverConnectThrd, NULL);
ASSERT_TRUE(send.load(DATA));
// Send just right amount
ASSERT_TRUE(client.sendBytes(send));
ASSERT_TRUE(client.sendBytes(send));
sleep(2);
ASSERT_TRUE(server.receiveBytes(recv, TWO_INTS));
ASSERT_EQ(TWO_INTS, recv.getBufferSize());
// Send too many bytes
ASSERT_TRUE(client.sendBytes(send));
ASSERT_TRUE(client.sendBytes(send));
ASSERT_TRUE(client.sendBytes(send));
ASSERT_TRUE(server.receiveBytes(recv, TWO_INTS));
ASSERT_EQ(TWO_INTS, recv.getBufferSize());
ASSERT_TRUE(server.receiveBytes(recv, ONE_INTS));
ASSERT_EQ(ONE_INTS, recv.getBufferSize());
}
示例2: while
// Utility for running tcp client in sending loop
void*
spinSender(void* arg)
{
TestClient* client = (TestClient*)arg;
ByteArray send;
const int DATA = 256;
send.load(DATA);
while(true)
{
client->sendBytes(send);
sleep(0.1);
}
}