How to check if TCP still up?

Hello, I'm leaning about networking, specifically the TCP protocol on zephyr and was curious about acknowledgement.

My goal is -

  • open socket     -> BSD function "socket"
  • connect            -> BSD function "connect"
  • send data         -> BSD function "send"
  • close socket     -> BSD function "close"

I have this communication working but what happens if the network fails. Using the BSD socket functions, "socket & connect " connect fails if the server is down. Lets say, the sever fails after the connect function. the send command still goes through with no issues. is there an acknowledgement to see if the data is sent successfully?

Parents Reply
  • Shahin97 said:
    but if the server is unplugged after the connect, the send command does not return any errors. (net tcp send some_string_of_data)

    True, you cannot always know if the connection is still alive until you try it.

    However, if the connection is reset, or closed properly, or the modem looses connection to the network and therefore closes the sockets, poll will let you know.

    But if the server just stops responding for whatever reason, you cannot know that until you try to send something to the server and the connection times out.

    Note that send() will return when the data has been placed in the modem queue, so if it is important for the application to get confirmation that the server has received the data, this must be handled in the application layer, e.g. with QoS 1 or 2 in MQTT.

Children
No Data
Related