From: Brian Candler Date: 2011-02-04T03:47:13+09:00 Subject: Re: Net::Telnet question Nick H. wrote in post #979220: > I am trying to use Net::Telnet to telnet to a website to check network > connectivity... That's the wrong tool for the job. If you just want to test that the remote end accepts a TCP connection, use a socket: require 'socket' TCPSocket.open("abc.xyz.com", 443) And this is all nicely wrapped up for you, complete with configurable timeout, in ping.rb in the standard ruby library (this may be somewhere like /usr/lib/ruby/1.8/ping.rb on your system) Read the file itself for examples how to use it. > On linux prompt i get the following output: > > $ telnet to abc.xyz.com 443 > Trying xxx.xxx.xxx.xxx... > Connected to abc.xyz.com. > Escape character is '^]'. > hello world > Connection closed by foreign host. That's because (1) you are typing something which is not valid HTTP, and so the server disconnects immediately, and (2) you are connecting to a HTTPS server (port 443), so it needs to talk SSL. A valid test would be: openssl s_client -connect abc.xyz.com:443 GET / HTTP/1.0 Host: abc.xyz.com But if you just want to check if the host is there, not whether SSL or HTTP are working, then ping.rb is what you want. Regards, Brian. -- Posted via http://www.ruby-forum.com/.