Boost asio TCP-соединение не получило данные после повторного подключения и чтенияC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Гость
 Boost asio TCP-соединение не получило данные после повторного подключения и чтения

Сообщение Гость »


I am using boost asio to connect to a TCP Server. When I run the code it works fine after start. I send the request and get the response. When I turn off the tcp server (it is a device) I am running into timeout and callback inside async_read from boost will never be executed when I am running into timeout. Then I close the socket. After turn on the device the connection could be re-established but then the recived buffer size is 0 bytes. I think thats because the async_read was not finished correctly after timeout.

header

Код: Выделить всё

#include  #include  #include  #include  #include  #include  #include  #include  #include  class TcpClient{     public:         int connect(boost::asio::ip::tcp::socket &socket, boost::asio::ip::tcp::endpoint &endpoint);         int writeAndRead(boost::asio::ip::tcp::socket &socket); }; 
This is the code

Код: Выделить всё

#include "tcpclient.h" int TcpClient::connect(boost::asio::ip::tcp::socket &socket, boost::asio::ip::tcp::endpoint &endpoint) {     boost::system::error_code error;     socket.connect(endpoint, error);     if (!error)     {         std::cout 

Источник: [url]https://stackoverflow.com/questions/78126690/boost-asio-tcp-connection-no-received-data-after-reconnecting-and-reading[/url]
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»