0

I've created a socket connection in c between my Raspberry Pi and another device where the Pi is the client.

Is there anyway to handle TCP flags in the packets received from the server?

In particular, I want certain code to execute if the response has a FIN flag.

nkr
  • 13
  • 1
  • Are you running Linux on your Raspberry Pi? – jxh Jul 31 '18 at 21:27
  • Possible duplicate of [how to get the tcp header of a received packet in socket programming?](https://stackoverflow.com/questions/15422041/how-to-get-the-tcp-header-of-a-received-packet-in-socket-programming) – Inrin Jul 31 '18 at 21:37

1 Answers1

0

You don't need to observe TCP flags to detect FIN. recv will return 0. If you want to try to observe whether or not recv would return 0 without disturbing the buffered data on the socket, you can use MSG_PEEK, and if you need it to be non-blocking, you can combine it with MSG_DONTWAIT.

jxh
  • 69,070
  • 8
  • 110
  • 193