Q: given a TCP receiver socket, how do you tell if it’s connected to a session or disconnected?
Shanyou said when you recv() on the socket but got 0 it means disconnected.
http://man7.org/linux/man-pages/man2/recv.2.html#RETURN_VALUE shows recv() return value of 0 indicates dead connection i.e. disconnected.
Q: given a UDP multicast receiver socket, how do you tell if it’s still has a live subscription to the multicast group?
%%A: I guess you can use getsockopt() to check socket /aliveness/. If alive but no data, then the group is quiet