This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to detect that the peer closed a TCP socket

Hello,

I am using the NCS v1.5.0, the nRF9160 SoC and the modem has firmware version mfw_nrf9160_1.2.3

Based on the UDP sample, I created an application that has opens a TCP listening server then waits for a client to connect. I am using blocking sockets and poll() to wait for events on the server and client sockets. My application is here tcp_listen.zip

It all works as expected, except that my application is not informed when the remote peer has closed the its end of the client socket.

Tracing with Wireshark on the remote peer side, I can see that when it closes the socket it sends a FIN+ACK packet. To which the nRF9160 modem sends an ACK. Nothing more happens. On the application, I expected that when the remote peer closes the client socket, the call to poll() would received a POLLIN, POLLHUP or POLLERR event. But nothing happens.

How can my application be informed that the remote peer has closed its end of the client socket ? 

Best regards,

  Nelson 

Parents
  • Hello Nelson,

    NelsonGoncalves said:
    Side note: I will be on vacation the next two and half weeks.

     thanks a lot for the heads-up.

    NelsonGoncalves said:
    Should I also try to update the modem firmware version ?

    I’m quite sure that this is not a modem issue, but to exclude this one from the list of possible root causes, I would appreciate if you could update and check with the newest mfw as well.

    NelsonGoncalves said:
    I tried with NCS v1.6.0 and using poll() for reading from the client socket. Again, when the remote client closes its end, nothing happens on the server side.

    I’ll inform our development team and let you know as soon as I get any news.

    I appreciate your patience!

    Regards,

    Markus

  • Hello Markus,

    I could not find the time to update the modem firmware, but I will try it out when I return from hollidays.

    Regards,

     Nelson

Reply Children
No Data
Related