[REBOL] Re: differences between script output and typing with tcp port
From: Gary::Jones::usap::gov at: 6-Apr-2004 16:56
===
On 5 Apr 2004 at 23:06, Anton Rolls wrote:
I think don't use /no-wait.
(You also might not need to use wait myPop, then ...)
Just a quick suggestion.
The difference between console typing session and
script is: the script doesn't pause in between...
===
From: Janeks
I experimented with wait / nowait - it is not a
reason.
....
===
Hi, Janeks,
I think you may not have fully understood what Anton was suggesting. I can't speak for
Anton, but I suspect that he was meaning that you may not have picked the ideal *combination*
of commands for use. Rewritten in a slightly different way:
***
print "Content-Type: text/plain"
print "" ; required
print "<html>"
print "<head>"
print "<title>Rebol script test</title>"
print "</head>"
print "<body>"
print "<h1>Hello!</h1>"
checkPop: func [user-name passe pop-server port-number] [
myCommands: ["user admin" "pass qwerty" "list"]
myPop: open/lines [
scheme: 'tcp
host: pop-server
port-id: port-number
]
response: pick myPop 1
probe response
print "<br>"
foreach myCom myCommands [
print join "<br>>" myCom
print "<br>"
insert myPop myCom
either mycom <> "list" [
response: pick myPop 1
probe response
][
while [(response: pick mypop 1) <> "."] [probe response]
]
]
print "</table>"
print "<pre>quit"
insert myPop "quit"
probe pick myPop 1
print "</pre>"
close myPop
]
checkPop "admin" "qwerty" "localhost" 110
print "</body>"
print "</html>"
****
In this version, the tcp open command reads by line but waits for the line. The pick
command picks the "first" response that comes in on the port, namely the first line.
The main "problem" that comes in are the multiline responses. In this case I borrowed
the technique used in the REBOL's POP scheme, namely read until an end marker is detected.
I left your program in the same form so that you can compare and contrast what I think
Anton meant with your own version.
It is fun to play with the TCP protocols as you have. For a better understanding of
master REBOL techniques, try reading through the REBOL POP scheme:
probe system/schemes/pop
and its companion support utilities:
probe net-utils
Hope that helps on ALL your platforms.
--Scott Jones