Hello [EMAIL PROTECTED]!
On 15-Mar-00, you wrote:
k>
k> When I tried the client-server example in the
k> network/ports section of
k> the user guide I found that the client can only do one
k> insert. The
k> next inserts are just ignored. Tests with a httpd confirm
k> this.
This is because the web server closes the connection after sending
the data.
k> p: open tcp://myserver:80
k> msg: "GET /index.html HTTP/1.0^j^j"
k> insert p msg
k> while [data: copy p] [print data]
At this point, the connection with the server is lost. Notice that
this has nothing to do with REBOL, but it's the way HTTP/1.0
works.
You could open a new connection to the server here.
k> Is there any method to maintain a persistent connection?
HTTP/1.1 provides such a possibility. It is a bit more complicated
as a protocol than 1.0, but I think you could just try forming
your request this way:
GET /index.html HTTP/1.1
Keep-Alive: yes
(hmm, not sure about that "yes"...)
However, since now the server should no more close the connection,
you are no more able to use COPY to get the data from the port
(COPY always waits until the port is closed by the remote host,
and then returns the whole data received --- so that WHILE above
isn't really needed); instead, you have to use READ-IO (or
COPY/PART if your port was opened as BINARY) to get the data.
>> help read-io
Low level read from a port.
Arguments:
port -- Already opened port to read from. (port)
buffer -- Buffer to which to append data. (series)
length -- Maximum number of chars to read. (number)
The buffer should have enough room for the data --- you can
preallocate it with, for e.g.:
buffer: make string! 1024
where the number indicates how many bytes to preallocate.
Regards,
Gabriele.
--
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o