本文整理汇总了C++中TCPSocket::sigio方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPSocket::sigio方法的具体用法?C++ TCPSocket::sigio怎么用?C++ TCPSocket::sigio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPSocket
的用法示例。
在下文中一共展示了TCPSocket::sigio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TCPSOCKET_RECV_100K_NONBLOCK
void TCPSOCKET_RECV_100K_NONBLOCK()
{
TCPSocket sock;
_tcpsocket_connect_to_chargen_srv(sock);
sock.set_blocking(false);
sock.sigio(callback(_sigio_handler, Thread::gettid()));
Timer timer;
timer.start();
rcv_n_chk_against_rfc864_pattern_nonblock(sock);
timer.stop();
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
printf("MBED: Time taken: %fs\n", timer.read());
}
示例2: TCPSOCKET_RECV_100K_NONBLOCK
void TCPSOCKET_RECV_100K_NONBLOCK()
{
TCPSocket sock;
nsapi_error_t err = _tcpsocket_connect_to_chargen_srv(sock);
if (err != NSAPI_ERROR_OK) {
TEST_FAIL();
return;
}
sock.set_blocking(false);
sock.sigio(callback(_sigio_handler, Thread::gettid()));
rcv_n_chk_against_rfc864_pattern_nonblock(sock);
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
}
示例3: test_tcp_echo_async
/**
* Test TCP data exchange via the asynchronous sigio() mechanism
*/
void test_tcp_echo_async()
{
TCPSocket sock;
SocketAddress host_address;
bool callback_triggered = false;
int x;
int size;
driver.disconnect();
TEST_ASSERT(do_connect(&driver) == 0);
TEST_ASSERT(
driver.gethostbyname(MBED_CONF_APP_ECHO_SERVER, &host_address) == 0);
host_address.set_port(MBED_CONF_APP_ECHO_TCP_PORT);
tr_debug("TCP: Server %s address: %s on port %d.",
MBED_CONF_APP_ECHO_SERVER, host_address.get_ip_address(),
host_address.get_port());
TEST_ASSERT(sock.open(&driver) == 0)
// Set up the async callback and set the timeout to zero
sock.sigio(callback(async_cb, &callback_triggered));
sock.set_timeout(0);
TEST_ASSERT(sock.connect(host_address) == 0);
// Test min, max, and some random sizes in-between
do_tcp_echo_async(&sock, 1, &callback_triggered);
do_tcp_echo_async(&sock, MBED_CONF_APP_TCP_MAX_PACKET_SIZE,
&callback_triggered);
sock.close();
drop_connection(&driver);
tr_debug("TCP packets of size up to %d byte(s) echoed asynchronously and successfully.",
MBED_CONF_APP_TCP_MAX_PACKET_SIZE);
}