posted 15 years ago
Netcat isn't usually provided with the base OS, but one reason you can't find it is because it's often installed with the name "nc".
"netstat -ln" can tell you if a port is listening for traffic. And yes, this does mean a "port" object has been created for the traffic to be routed to, so some of the OS component display utilities will also show it, but netstat is your best bet.
A port can be listening in one of 2 ways:
1. Directly. A (server) app opens the port and listens on it.
2. Indirectly. The super-server (inetd/xinetd) may dynamically fire up services on receipt of traffic on that port. Technically I suppose that the super-server could dissect any unclaimed traffic, but I was working on a Linux box the other day and it looked like the super-server was opening ports just like a server app would, so a netstat -ln would see that as well.
Super-servers aren't used as much as they were when hardware was less powerful. They permit servers to fire on demand, but the price is slower initial connection.
Telnet can respond in one of 3 ways to traffic.
1. If the server is a text-based service, you'll usually get back a text response. Text-based services include HTTP servers, mailers, FTP (the command port) and many of the older Internet services where portability was important and being able to walk/debug the protocols via manual telnet input was useful.
2. If the service provides a binary service, your telnet client will usually hang waiting for the proper input. Sometimes it may spit binary gunk back at you. Unless you're really, really good at typing in binary, the main value here is that you know you're connecting to something.
3. If there is no available service on the selected machine/port, telnet will return an "unable to connect" message.
Telnet's prime virtue for network debugging is that it can tell you not only that the target machine is listening, but that there's nothing blocking traffic (e.g. a firewall).
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.