summaryrefslogtreecommitdiff
path: root/sample/openssl/echo_svr.rb
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 07:31:23 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 07:31:23 +0000
commita3bfedac36e946790c966c0319765479df770e4b (patch)
tree65a7e313612bef6245f1f0052308aace47e0da84 /sample/openssl/echo_svr.rb
parent8fd40444465a6165f08490269f8e0b142edc2824 (diff)
* sample/openssl: reviewed and remove dependency on getopts.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/openssl/echo_svr.rb')
-rw-r--r--sample/openssl/echo_svr.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/sample/openssl/echo_svr.rb b/sample/openssl/echo_svr.rb
index be8e10fa26c..719de6be843 100644
--- a/sample/openssl/echo_svr.rb
+++ b/sample/openssl/echo_svr.rb
@@ -2,14 +2,14 @@
require 'socket'
require 'openssl'
-require 'getopts'
+require 'optparse'
-getopts nil, "p:2000", "c:", "k:", "C:"
+options = ARGV.getopts("p:c:k:C:")
-port = $OPT_p
-cert_file = $OPT_c
-key_file = $OPT_k
-ca_path = $OPT_C
+port = options["p"] || "2000"
+cert_file = options["c"]
+key_file = options["k"]
+ca_path = options["C"]
if cert_file && key_file
cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
@@ -55,8 +55,11 @@ tcps = TCPServer.new(port)
ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
loop do
ns = ssls.accept
+ puts "connected from #{ns.peeraddr}"
while line = ns.gets
+ puts line.inspect
ns.write line
end
+ puts "connection closed"
ns.close
end