Given a socket, how to find its protocol (i.e., UDP or TCP)?
The thing I have in mind is using “getsockname()” ==> sockaddr_in.
But “sockaddr_in” seems to have no protocol information, only family.
When a socket is created, protocol is supplied. I just what to know how to retrieve.
Thanks for the help.
Check the
SO_PROTOCOLand/orSO_TYPEsocket options withgetsockopt(2).