Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush TCP socket on exception #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stefanb2
Copy link
Contributor

Not all bytes may have been read from the TCP socket read buffer when the request processing is aborted by an exception.

  • remember the frame length from the message header
  • derease remaining length on every successful read
  • after sending the exception flush any remaining bytes from the socket

Fixes #67

@stefanb2
Copy link
Contributor Author

recv() could be updated now to detect the situation when request processing tries to read more bytes than are remaining in the Modbus TCP frame...

@stefanb2 stefanb2 force-pushed the topic-flush-socket-on-exception branch from d8a1b5a to 2a5342a Compare September 27, 2024 05:20
Not all bytes may have been read from the TCP socket read buffer when
the request processing is aborted by an exception.

- remember the frame length from the message header
- frame length must be at least 2 octets
- decrease remaining length on every successful read
- after sending the exception flush any remaining bytes from the socket

Fixes debevv#67
@stefanb2 stefanb2 force-pushed the topic-flush-socket-on-exception branch from 2a5342a to 8d75d44 Compare October 7, 2024 05:14
- don't write more data to socket than is left in buffer
- add missing LF in client printf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TCP read out-of-sync after exception
1 participant