function::sock_prot_num2str - Linux


sock_prot_num2str is a utility command used to convert a socket protocol number into its corresponding name. It’s particularly useful for debugging network-related issues or when you need to identify the protocol used by a specific port.


sock_prot_num2str [protocol number]




  • protocol number: The numeric ID of the socket protocol.


The output of sock_prot_num2str is the name of the protocol corresponding to the given protocol number. If the protocol number is invalid or not recognized, it returns an error message.


  • Convert protocol number 6 to its name:
$ sock_prot_num2str 6
  • Convert an invalid protocol number:
$ sock_prot_num2str 99
Invalid protocol number

Common Issues

  • Incorrect protocol number: Ensure that you provide a valid protocol number. You can use the getprotobynumber(3) function to obtain a list of valid protocol numbers.


sock_prot_num2str can be used in conjunction with other network troubleshooting tools, such as netstat(1) or tcpdump(1). For example, you can use sock_prot_num2str to identify the protocol used by a specific port in a netstat output:

$ netstat -atpu | grep 80
tcp        0      0*               LISTEN      4848/nginx: master
$ sock_prot_num2str 6

Related Commands

  • getprotobynumber(3): Gets protocol information by number.
  • getprotobyname(3): Gets protocol information by name.
  • netstat(1): Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
  • tcpdump(1): Captures and displays packets on a network interface.