From ba64282cdc2e02a742ae5e0159d606051f188aa5 Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Mon, 18 Aug 2003 22:49:48 +0000 Subject: * ext/openssl/ossl_ssl.c: sync_close is moved to SSLSocket as a builtin. * ext/openssl/lib/openssl/buffering.rb (Buffering#close): ditto. * ext/openssl/lib/openssl/buffering.rb (Buffering#puts): should add a return to the tails of each line. * ext/openssl/lib/openssl/ssl.rb: new class OpenSSL::SSL::SSLServer. * ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): use sync_close. * ext/openssl/sample/echo_svr.rb: use SSLServer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/sample/echo_cli.rb | 5 +++-- ext/openssl/sample/echo_svr.rb | 12 +++++------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'ext/openssl/sample') diff --git a/ext/openssl/sample/echo_cli.rb b/ext/openssl/sample/echo_cli.rb index 87dacaf545..29b356a7ad 100644 --- a/ext/openssl/sample/echo_cli.rb +++ b/ext/openssl/sample/echo_cli.rb @@ -26,11 +26,12 @@ end s = TCPSocket.new(host, port) ssl = OpenSSL::SSL::SSLSocket.new(s, ctx) -ssl.connect +ssl.connect # start SSL session +ssl.sync_close = true # if true the underlying socket will be + # closed in SSLSocket#close. (default: false) while line = $stdin.gets ssl.write line print ssl.gets end ssl.close -s.close diff --git a/ext/openssl/sample/echo_svr.rb b/ext/openssl/sample/echo_svr.rb index e35ad12a19..be8e10fa26 100644 --- a/ext/openssl/sample/echo_svr.rb +++ b/ext/openssl/sample/echo_svr.rb @@ -51,14 +51,12 @@ else $stderr.puts "!!! WARNING: PEER CERTIFICATE WON'T BE VERIFIED !!!" end -svr = TCPServer.new(port) +tcps = TCPServer.new(port) +ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx) loop do - ns = svr.accept - ssl = OpenSSL::SSL::SSLSocket.new(ns, ctx) - ssl.accept - while line = ssl.gets - ssl.write line + ns = ssls.accept + while line = ns.gets + ns.write line end - ssl.close ns.close end -- cgit v1.2.3