With buffering, which was taken care of in previous posts, to solve the question of whether data is being sent, consider capturing data in a string using wireshark . If the data you send is visible on the line, then the server does not receive it.
Otherwise, if the data does not go to the string, TCP may contain data to avoid sending one segment with several bytes in it ( see the Nagle algorithm ). Depending on your OS or TCP provider, you may have different behavior, but most TCP stacks support the TCP_NODELAY parameter, which can help you receive data more timely.
tcp_client.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
This can help debugging, but as a rule, it cannot be left in production code if bandwidth has a higher priority than responsiveness.
Greg
source share