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

Ensure empatica stream is not breaking messages into half-lines #50

Open
glopesdev opened this issue Nov 30, 2023 · 0 comments
Open

Ensure empatica stream is not breaking messages into half-lines #50

glopesdev opened this issue Nov 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@glopesdev
Copy link
Member

The current implementation seems to assume that available bytes in the TCP buffer always represent whole messages (i.e. ending with a newline) but this cannot be guaranteed in general.

while ((line = reader.ReadLine()) != null)

The easiest way to fix this is simply to create a StreamReader directly on top of the TCP stream and just ReadLine in the task loop. Internally the reader will take care of managing all the stream state automatically.

@glopesdev glopesdev added the bug Something isn't working label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant