동시에 데이터를주고받을 수 있어야하는 TCP 클라이언트를 작성합니다. async_send
과 async_receive
을 별도의 스레드라고 어떻게 부를 수 있습니까? 다른 말로부스트 비동기 소켓 및 부스트 :: 스레드
방법
boost::thread receivingThread(boost::bind(...));
boost::thread sendingThread(boost::bind(...));
에서
m_Socket.async_send(boost::asio::buffer(txBuf.c_str(), txBuf.length()+1),
boost::bind(&TCPClient::sendingHandler, this, boost::asio::placeholders::error));
m_Socket.async_receive(boost::asio::buffer(rxBuf, maxBufLen),
boost::bind(&TCPClient::sendingHandler, this, boost::asio::placeholders::error));
를 호출하는 내가 핸들러 내부에 다시 async_send
또는 async_receive
를 호출하는 경우 올바르게 작동합니까? 데이터를 전송/수신하기위한 무한 반복이 필요합니다.
동시 송수신을 위해 별도의 스레드가 필요하지 않습니다. 같은 스레드에서'async_send'와'async_receive'를 호출하면,'io_service'가 그것을 대신 할 것입니다. –