Using Telnet to Test Socket Connectivity


Although Telnet should not be used as a remote login protocol, it is very useful as a technique for testing the ability for your machine to communicate successfully with a remote computer socket. You are, in essence, mimicking the exact communication that computers use to communicate with each other across sockets.

For instance, if you can Telnet from your machine to a remote machine on port 80, you can send HTTP commands to verify that your machine has unencumbered access (no network or firewall blocks) to that Web server.

The syntax for adding a port to the hostname/IP address when using Telnet is

Telnet remote-hostname-or-IP remote-port-number-or-service-name


For the optional second argument, either a port number or the name specified in /etc/services can be used.

Both of the following would be equivalent:

Telnet www.apple.com 80 Telnet www.apple.com http


If you are successful in reaching the remote socket, you will see something like this:

albook:~ smn$ Telnet www.apple.com http Trying 17.254.0.91... Connected to www.apple.com. Escape character is '^]'.


Quit the Telnet session by typing the characters in the line Escape character is '^]'., in this case Ctrl-]. You will then be back at the Telnet prompt, and can enter q and press Return to quit. If you take too long, the remote server may automatically disconnect you.

Common protocols that communicate in this manner include HTTP, SMTP, POP, IMAP, and so on.

Note that Telnet does not work with SSL-encrypted sockets, but there is an equivalentsee man s_client (part of OpenSSL), specifically the connect option.




Apple Training Series. Mac OS X System Administration Reference, Volume 1
Apple Training Series: Mac OS X System Administration Reference, Volume 1
ISBN: 032136984X
EAN: 2147483647
Year: 2005
Pages: 258
Authors: Schoun Regan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net