Here's a piece of test code I've used in
the past:
# This proc is run when a connection occurs
proc handle_socklistencallback {rfd wfd}
{
ns_log notice "A client has connected to the socket"
while {[set line [string trim [gets $rfd]]] != ""} {
lappend headers $line
}
ns_log notice "CLIENT HTTP HEADERS:"
ns_log notice "$headers"
ns_log notice "A client has connected to the socket"
while {[set line [string trim [gets $rfd]]] != ""} {
lappend headers $line
}
ns_log notice "CLIENT HTTP HEADERS:"
ns_log notice "$headers"
set content_htm
\
"<html>
<head>
<title>non-ssl test</title>
</head>
<body>
<p>Great! We were able to do a listen-callback on a socket,
read the client HTTP header and send back this HTML page. Hit the back
button to return to the test page.
<p>Here ar the HTTP client headers you sent me:
<p>$headers
</body>
</html>"
"<html>
<head>
<title>non-ssl test</title>
</head>
<body>
<p>Great! We were able to do a listen-callback on a socket,
read the client HTTP header and send back this HTML page. Hit the back
button to return to the test page.
<p>Here ar the HTTP client headers you sent me:
<p>$headers
</body>
</html>"
set myheader
\
"HTTP/1.0 200 Document follows
MIME-Version: 1.0
Content-Type: text/html
Content-Length: [string length $content_htm]"
"HTTP/1.0 200 Document follows
MIME-Version: 1.0
Content-Type: text/html
Content-Length: [string length $content_htm]"
puts $wfd
\
"$myheader
"$myheader
$content_htm"
flush
$wfd
close $rfd
close $wfd
}
close $rfd
close $wfd
}
# This starts the listener on an address
and port, and tells it
# what proc to run when a connection comes
in
ns_socklistencallback 192.168.0.2 8443
handle_socklistencallback
/s.
-----------------------------------------------------------------------
Scott S. Goodwin
e: [EMAIL PROTECTED] | u: http://scottg.net
aim: scottgnet
Scott S. Goodwin
e: [EMAIL PROTECTED] | u: http://scottg.net
aim: scottgnet
----- Original Message -----
From: "David Walker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 24, 2002 10:23
AM
Subject: [AOLSERVER]
ns_socklistencallback
>
>