From Derek Leung on Wed, 05 May 1999
I am just wondering if there is any way that I can code to ping a destination if it is alive or not. However, the server is known to be behind a firewall, and only one port is open to public. So, is there anyone know how to code a "ping" program that could ping on a certain port? I will greatly appreciate for any ideas.
The 'ping' command generates an ICMP echo request packet. ICMP is a protocol over IP that implements "control messages" (flow control, routing, etc.). At level the very concept of TCP/UDP ports is completely irrelevant. (TCP and UDP are other protocols that ride over IP, they are orthogonal to ICMP).
There are a number of programs that you can use for port scanning (and your application seems to call for testing a single port on a single host --- which is a very short list ports to scan). I'd recommend that you look at netcat (sometimes installed as 'nc' on some Linux systems) and nmap.
A quick place to find these and many other interesting tools would be the Trinux web site: http://www.trinux.org
PS. I use PERL to code. If there are any available C module, please let me know too. Thanks.
There are some sophisticated PERL sockets and RAW::IP tools --- you'd want to look at CPAN (http://www.cpan.org) for those. There are numerous modules to allow easy PERL coding for specific network protocols and services --- and there are many sample scripts there.