[REBOL] Reading tcp ports in rebol line by line
From: al:bri:xtra at: 9-Nov-2000 17:55
> what was the bug in tcp ports?
The bug in rebol was two things:
1 A empty port in line mode doesn't produce none, it just waits for data.
2 An empty port always has a rebol newline character in it's buffer.
I found this function for a server to be the best (so far) to read all of
the headers of a http request from a client.
Web: function [
Port [integer!] Root [file!] /Print-Request
Request Line Filename Error Disarmed
Listen: open/lines join tcp://: Port
while [not Stop] [
Request: make string! 1000
Connection: first Listen
if error? Error: try [
while [not empty? Line: Read-Connection] [
append Request rejoin [Line newline]
Service Request Root :Read-Connection
if Print-Request [print ["Request:" mold Request] none]
Disarmed: disarm Error
either all [
Disarmed/type = 'access
Disarmed/id = 'timeout