I'd like to see this as a feature of AOLServer... being able to mark a
channel as do-not-cleanup.
Rusty
Michael A. Cleverly wrote:
On 9/6/06, John Buckman <[EMAIL PROTECTED]> wrote:
I'd like to keep a permanently connected socket connection to another
machine, with each aolserver thread having a socket that is already
connected to that other app.
I tried using the namespace trick to keep a global around, like so:
namespace eval sbuff {}
proc mysockget {} {
global sbuff:mysock
if {[info exists mysock] == 1} {
return $mysock
}
set mysock [socket localhost 9999]
}
but while the socket descriptor stays around with this trick,
aolserver automatically closes the socket itself. This must be some
sort of cleanup code in aolserver, normally a good thing.
Is there a way to either:
1) have my socket NOT be cleaned up by aolserver
2) have a connected socket pool, like nsdb, but w/o any functionality
other than a connected socket
I'm not alone with this need, I know that Rusty needs to do this too,
and lots of tcpip socket protocols have login steps, that cause a new-
connection-per-adp-page strategy to be inefficient.
This does seem like a very useful feature to have...
The code that closes the socket is ns_cleanupchans defined in
nsd/init.tcl (in the 4.5 source distribution). It is called by
ns_cleanup. You could modify your ns_cleanupchans to ignore (in
addition to the stdin/stdout/stderr channels it already ignores) the
chan in your sbuf::mysock variable. I.e., something like:
proc ns_cleanupchans {} {
ns_chan cleanup; # close shared channels first
set except ""
if {[info exists ::sbuf::mysock]} {
set except $::sbuf::mysock
}
foreach f [file channels] {
# NB: Leave core Tcl stderr, stdin, stdout open.
if {![string match std* $f]} {
if {$f != $except} {
catch {close $f}
}
}
}
}
Michael
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to
<[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the
Subject: field of your email blank.
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.