<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>OK this is actually very easy. The IO::Socket::SSL docs mention how to do non-blocking correctly, but it looks like the package was taken over and specifically improved in this arena around the time of this original discussion. So who knows, maybe it wasn't clear how to do this before now. Anyway, this simple patch fixes the issue and doesn't change the requirements or need danga::socket updates. The trick is to promote a normal IO::Socket::INET socket to an ssl socket with IO::Socket::SSL-&gt;start_SSL() after the accept(). I'm making the call in an eval, because if the start_SSL() call fails to establish an ssl socket, the socket silently remains a plain old non-ssl socket and would be handled the same as if you were missing the SSL module I believe. Thoughts? Haven't gotten a chance to test it extensively, but it looks to me like identical functionality. Here's the patch. Let me apologize in advance in case my mail client screws this up.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Index: TCPListener.pm</DIV><DIV>===================================================================</DIV><DIV>--- TCPListener.pm      (revision 699)</DIV><DIV>+++ TCPListener.pm      (working copy)</DIV><DIV>@@ -11,7 +11,7 @@</DIV><DIV> no  warnings qw(deprecated);</DIV><DIV> use base "Perlbal::Socket";</DIV><DIV>-use fields qw(service hostport);</DIV><DIV>+use fields qw(service hostport sslopts);</DIV><DIV> use Socket qw(IPPROTO_TCP SOL_SOCKET SO_SNDBUF);</DIV><DIV> # TCPListener</DIV><DIV>@@ -19,16 +19,12 @@</DIV><DIV>     my ($class, $hostport, $service, $opts) = @_;</DIV><DIV>     $opts ||= {};</DIV><DIV>-    my $sockclass = $opts-&gt;{ssl} ? "IO::Socket::SSL" : "IO::Socket::INET";</DIV><DIV>-    my $sock = eval {</DIV><DIV>-        $sockclass-&gt;new(</DIV><DIV>-                        LocalAddr =&gt; $hostport,</DIV><DIV>-                        Proto =&gt; IPPROTO_TCP,</DIV><DIV>-                        Listen =&gt; 1024,</DIV><DIV>-                        ReuseAddr =&gt; 1,</DIV><DIV>-                        ($opts-&gt;{ssl} ? %{$opts-&gt;{ssl}} : ()),</DIV><DIV>-                        );</DIV><DIV>-    };</DIV><DIV>+    my $sock = IO::Socket::INET-&gt;new(</DIV><DIV>+                                     LocalAddr =&gt; $hostport,</DIV><DIV>+                                     Proto =&gt; IPPROTO_TCP,</DIV><DIV>+                                     Listen =&gt; 1024,</DIV><DIV>+                                     ReuseAddr =&gt; 1,</DIV><DIV>+                                     );</DIV><DIV>     return Perlbal::error("Error creating listening socket: " . ($@ || $!))</DIV><DIV>         unless $sock;</DIV><DIV>@@ -48,6 +44,7 @@</DIV><DIV>     my $self = $class-&gt;SUPER::new($sock);</DIV><DIV>     $self-&gt;{service} = $service;</DIV><DIV>     $self-&gt;{hostport} = $hostport;</DIV><DIV>+    $self-&gt;{sslopts} = $opts-&gt;{ssl};</DIV><DIV>     bless $self, ref $class || $class;</DIV><DIV>     $self-&gt;watch_read(1);</DIV><DIV>     return $self;</DIV><DIV>@@ -60,10 +57,10 @@</DIV><DIV>     # accept as many connections as we can</DIV><DIV>     while (my ($psock, $peeraddr) = $self-&gt;{sock}-&gt;accept) {</DIV><DIV>         my $service_role = $self-&gt;{service}-&gt;role;</DIV><DIV>+        my ($pport, $pipr) = Socket::sockaddr_in($peeraddr);</DIV><DIV>+        my $pip = Socket::inet_ntoa($pipr);</DIV><DIV>         if (Perlbal::DEBUG &gt;= 1) {</DIV><DIV>-            my ($pport, $pipr) = Socket::sockaddr_in($peeraddr);</DIV><DIV>-            my $pip = Socket::inet_ntoa($pipr);</DIV><DIV>             print "Got new conn: $psock ($pip:$pport) for $service_role\n";</DIV><DIV>         }</DIV><DIV>@@ -73,6 +70,19 @@</DIV><DIV>             my $rv = setsockopt($psock, SOL_SOCKET, SO_SNDBUF, pack("L", $sndbuf));</DIV><DIV>         }</DIV><DIV>+        if ($self-&gt;{sslopts}) {</DIV><DIV>+            if (Perlbal::DEBUG &gt;= 1) {</DIV><DIV>+                print "Promoting to SSL socket: $psock ($pip:$pport) for $service_role\n";</DIV><DIV>+            }</DIV><DIV>+            eval {</DIV><DIV>+                IO::Socket::SSL-&gt;start_SSL(</DIV><DIV>+                                           $psock,</DIV><DIV>+                                           SSL_server =&gt; 1,</DIV><DIV>+                                           %{$self-&gt;{sslopts}}</DIV><DIV>+                                           );</DIV><DIV>+            };</DIV><DIV>+        }</DIV><DIV>+</DIV><DIV>         if ($service_role eq "reverse_proxy") {</DIV><DIV>             Perlbal::ClientProxy-&gt;new($self-&gt;{service}, $psock);</DIV><DIV>         } elsif ($service_role eq "management") {</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV><DIV>On Sep 25, 2007, at 10:40 PM, Brad Fitzpatrick wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">On Tue, 25 Sep 2007, Robin H. Johnson wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">On Tue, Sep 25, 2007 at 03:53:21PM -0500, Greg Thornton wrote:</DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Ok so where might one find Danga::Socket::SSL right now? Maybe I just can't</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">operate CPAN correctly, but it doesn't seem to be in there. I'd LOVE to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">give this a shot. Granted I haven't touched perl in a while, but it sounds</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">like the hard part is done. Coincidentally I'd try to tackle the OPTIONAL</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">ssl dependency route described by Brad. Thanks dudes.</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://code.sixapart.com/svn/Danga-Socket-SSL/">http://code.sixapart.com/svn/Danga-Socket-SSL/</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I don't know if there is any more recent version. bradfitz might be able</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">to say more canonically.</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">That's it, but I can't recall if I ever fully got it working... it seems I</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">would've released it if I had.<SPAN class="Apple-converted-space">  </SPAN>Use with caution.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">- Brad</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#BA6725" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(186, 103, 37); font-family: Verdana; "><B style="color: rgb(186, 103, 37); font-family: Verdana; font-size: 11px; font-weight: bold; "><SPAN class="Apple-style-span" style="color: rgb(186, 103, 37); font-family: Verdana; font-size: 11px; font-weight: bold; ">Greg Thornton</SPAN></B></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; ">Senior Developer | </SPAN></SPAN></FONT><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><B style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; font-weight: bold; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; font-weight: bold; ">EmmaŽ </SPAN></B></SPAN></FONT></DIV><A href="mailto:greg@myemma.com"><SPAN class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; ">greg@myemma.com</SPAN></A><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; ">800.595.4401 or 615.292.5888 x112</SPAN></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; ">615.292.0777 (fax)</SPAN></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Verdana; min-height: 13px; ; font-family: Verdana; font-size: 11px; "><FONT class="Apple-style-span" color="#333333"><BR style="; color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; "></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; ">Emma helps organizations everywhere communicate &amp; market in style.</SPAN></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#333333" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(51, 51, 51); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; font-size: 11px; ">Visit us online at </SPAN></SPAN></FONT><A href="http://www.myemma.com/"><FONT class="Apple-style-span" face="Verdana" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;; color: rgb(0, 0, 238); font-family: Verdana; -khtml-text-decorations-in-effect: underline; "><SPAN class="Apple-style-span" style="color: rgb(0, 0, 238); font-family: Verdana; font-size: 11px; -khtml-text-decorations-in-effect: underline; ">http://www.myemma.com</SPAN></SPAN></FONT></A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" color="#4F7927" face="Webdings" size="6"><SPAN class="Apple-style-span" style="font-size: 24px;; color: rgb(79, 121, 39); font-family: Webdings; "><SPAN class="Apple-style-span" style="color: rgb(79, 121, 39); font-family: Webdings; font-size: 24px; ">P </SPAN></SPAN></FONT><FONT class="Apple-style-span" color="#4F7927" face="Verdana" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;; color: rgb(79, 121, 39); font-family: Verdana; "><SPAN class="Apple-style-span" style="color: rgb(79, 121, 39); font-family: Verdana; font-size: 10px; ">please consider the environment before printing this e-mail</SPAN></SPAN></FONT></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>