no-wait for scheme
[1/3] from: patrick:philipot:laposte at: 18-Aug-2003 9:45
Hi List,
Previously on "Understanding tcp"
My previous problem, while trying to code a Rebol Client, was that 'copy
never returned any value.
>> serv: open/binary tcp://localhost:3000
>> insert serv "^(05)^(00)^(0A)^(00)^(00)^(01)DSN=mytest;"
>> insert serv "^(05)^(00)^(17)^(00)^(00)^(02)SELECT * from
mytable^(0D)^(0A)"
>> insert serv "^(05)^(00)^(0B)^(00)^(00)^(06)FetchRecord"
>> copy serv
** Access Error: Network timeout
** Near: copy serv
>> close serv
Thanks to Maarten, Gabriele, and Norman, it is working now.
The /no-wait refinement was needed in my case.
My problem now is to use no-wait in a 'scheme.
The scheme is very short:
make root-protocol [
scheme: 'dbtcp
port-id: 3000
port-flags: system/standard/port-flags/pass-thru
open-check: none
open: func [port [port!] /local connection-string][
open-proto port
port/sub-port/state/flags: 524835 ; force /direct/binary mode
connection-string: system/words/copy
^(05)^(00)^(0A)^(00)^(00)^(01)
if not none? port/target [ append connection-string join "DSN="
port/target ";" ] ]
if not none? port/user [ append connection-string join "UID="
port/user ";" ] ]
if not none? port/pass [ append connection-string join "PWD="
port/pass ";" ] ]
insert port connection-string
]
insert: function [ port data ] [ ] [
system/words/insert port/sub-port data
]
copy: func [ port ] [
make string! system/words/copy port/sub-port
]
net-utils/net-install dbtcp self 3000
]
The test program is very short too.
Rebol[]
trace/net on
do %dbtcp-scheme.r
db: open dbtcp://localhost/mytest
insert db rejoin ["^(05)^(00)^(17)^(00)^(00)^(02)" "select * from mytable"
^(0D)^(0A)
]
insert db "^(05)^(00)^(0B)^(00)^(00)^(06)FetchRecord"
print mold copy db ; <<<<<<<<<<<<<< TIMEOUT ERROR
close db
I can tell that all this work pretty well because tcpview shows a correct
trace. The server is receiving and sending its data.
However, as before, I am not in no-wait mode. And so the copy fails.
I have looked deeply in the code of all existing protocols but found
nothing..
Does anybody have a clue?
Regards
Patrick
[2/3] from: dockimbel:free at: 18-Aug-2003 10:13
Bonjour Patrick,
You should try to use 'set-mode instead of setting port flags.
(Warning: untested!)
Replace the line :
port/sub-port/state/flags: 524835
by :
set-mode port/sub-port [direct: binary: no-wait: true]
or maybe :
set-mode port [direct: binary: no-wait: true]
Let us know if this works correctly.
HTH,
-DocKimbel
Selon [patrick--philipot--laposte--net]:
[3/3] from: patrick::philipot::laposte::net at: 19-Aug-2003 9:27
Hi Nenad,
None of your suggestions did work. However it forces me to look into this
more deeper.
So in the end I replaced this line (1) by this line(2).
(1) port/sub-port/state/flags: 524835
(2) port/sub-port/state/flags: 526883
Where did this *magic* value come from? A simple probe on the opened port
(see below).
Anyway, thanks for your help.
It put me back on track when I was about to give up.
Regard
Patrick
>> db: open/binary/no-wait tcp://localhost:3001
>> probe db
make object! [
scheme: 'tcp
host: "localhost"
port-id: 3001
user: none
pass: none
target: none
path: none
proxy: none
access: none
allow: none
buffer-size: none
limit: none
handler: none
status: none
size: none
date: none
url: none
sub-port: none
locals: none
state:
make object! [
flags: 526883 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE
misc: [308 [] 0]
tail: 0
num: 0
with: "^M^/"
custom: none
index: 0
func: 3
fpos: 0
inBuffer: none
outBuffer: none
]
timeout: none
local-ip: 127.0.0.1
local-service: none
remote-service: none
last-remote-service: none
direction: none
key: none
strength: none
algorithm: none
block-chaining: none
init-vector: none
padding: none
async-modes: none
remote-ip: 127.0.0.1
local-port: 4882
remote-port: 3001
backlog: none
device: none
speed: none
data-bits: none
parity: none
stop-bits: none
rts-cts: true
user-data: none
awake: none
]