Forum OpenACS Q&A: Response to tcllib nntp

Collapse
4: Response to tcllib nntp (response to 1)
Posted by Dan Wickstrom on
You're opening a new socket connection to the news server each time you get a new news handle, so even though you're calling quit in the news handle, each of the sockets is in a TIME_WAIT state.  If you use something like netstat or lsof, you should be able to see that you have a bunch of socket connections open to the news server when you get the error.  Once the TIME_WAIT state expires, you're then able to reopen new connections.
<p>
To fix this, you need to reuse the news handle when you source the page again.
<p>
Try something like the following:
<p>
<pre>
    global NH
          if ![info exists NH] {
              set NH [::nntp::nntp]
        }
        $NH authinfo "username" "password"
</pre>
<p>
Using this approach, the news handle should stick around until the connection thread is cleaned up and the interpreter is deallocated, so if the server is not idle, the same news handle will be used for multiple connections.