Skip to content

Commit

Permalink
don't skip initial data on tcp
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Feb 24, 2024
1 parent 741860f commit 6d49fd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/ebus/transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ result_t NetworkTransport::openInternal() {
if (m_fd < 0) {
return RESULT_ERR_GENERIC_IO;
}
if (!m_udp) {
usleep(25000); // wait 25ms for potential initial garbage
}
int cnt;
symbol_t buf[MTU];
int ioerr;
while ((ioerr=ioctl(m_fd, FIONREAD, &cnt)) >= 0 && cnt > 1) {
if (!m_udp) {
break; // no need to skip anything on a fresh TCP connection
}
// skip buffered input
ssize_t read = ::read(m_fd, &buf, MTU);
if (read <= 0) {
Expand Down

0 comments on commit 6d49fd7

Please sign in to comment.