"IO::Socket::INET: Bad protocol 'tcp'"
IO::Socket::INET: Bad protocol 'tcp' at /tmp/script.pl line 7, <DATA> line 225.
You may receive this error if your system cannot convert the tcp protocol to its number using getprotobyname().
$ getent protocols tcp $
In my case, this happened because after configuring a Solaris LDAP client using ldapclient. This command copies /etc/nsswitch.ldap over /etc/nsswitch.conf. The problematic line:
$ grep protocols /etc/nsswitch.conf protocols: ldap [NOTFOUND=return] files
I changed the line to:
protocols: files ldap
and had no more problems.
$ getent protocols tcp tcp 6 TCP