Thanks Holger.  I'll try the xper but I really need to stick
with a stable release at this point.  It looks like I can use
the /binary refinement and copy/part to get the data and that
should work for now.

One possible problem I saw though.  I want to check whether there
is data waiting on the port before trying to copy.  I see the 
users guide says to use 'wait like [wait c 1] to wait on 
port c for 1 second.  However, if I do the following:

>> c: open/binary tcp://host:23
>> print copy/part c 100
>> #{FFFD18FFFD1FFFFD23FFFD27FFFD24}
>> wait c 1   ;should return after 1 second because there is no more data
/ (never returns from waiting)

It doesn't seem like wait is working correctly.

Basically I need something like the select() socket function.
Am I doing the right thing here?

Thanks again,
 
Rodney


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 07, 2000 3:47 PM
To: [EMAIL PROTECTED]
Subject: [REBOL] Network Port Reading Problem Re:


On Thu, Sep 07, 2000 at 03:18:38PM -0700, [EMAIL PROTECTED] wrote:
> I need to implement a telnet client in Rebol for a fixed task (that is, I
> don't
> want a terminal type thing - all client commands are fixed and will be run
> with no user interaction).

Try something like this. Only works with current experimental versions of
REBOL (www.rebol.com/xpers/xpers.html) though.

peer: open/direct/binary/no-wait tcp://myhost:23

forever [
        wait peer
        input-data: copy peer
        ; Handle your data here and insert the response, e.g.
        ; insert peer #{fffc25}
        ; The following print is just an example...
        print input-data
]

The direct/no-wait ensures that copy returns whatever data is available.
Without
it copy usually blocks until the peer signals end-of-file. The wait is
necessary
to avoid busy-looping on copy. If copy returns an empty series (#{}) then
this means
no data is available (should not happen after a wait). If copy returns none
then the
peer has closed the connection.

-- 
Holger Kruse
[EMAIL PROTECTED]

Reply via email to