sock: tcp: fix sock_tcp_read() example#16743
Conversation
maribu
left a comment
There was a problem hiding this comment.
Note that the example is currently conaistent with the API doc. According to the current API doc, there is no way to detect when a TCP connection is closed. That obviously is a design flaw in need to be fixed. I trust that the implementation already has been fixed, but fixing the was forgotten. Care to add a commit to fiz this? Also, the @retval Doxygen command would make sense for documenting the individual magic return constants.
|
TBH I'm a bit surprised it does not return |
|
Maybe it is worth to discuss the correct behaviour first. But note: Both POSIX |
-ECONNABORTED is used as an error condition. Closing a connection normally is not an error. TCP assumes that a connection can be closed from any participating peer at any time regardless of what the peer is currently doing. Think of recv for example: |
sock_tcp_read() will return 0 if the connection was closed, we need to check for this.
ea236b4 to
c3849ed
Compare
fjmolinas
left a comment
There was a problem hiding this comment.
LGTM and @brummer-simon is fine with the change. ACK.
Contribution description
sock_tcp_read()will return 0 if the connection was closed, we need to check for this.Testing procedure
Issues/PRs references
#16494 (comment)