[REBOL] Understanding tcp
From: patrick::philipot::laposte::net at: 15-Aug-2003 19:18
Hi List
I am still struggling to build a Rebol Client for dbtcp.
(dbtcp is a server for ODBC databases).
I am able to send dbtcp my requests, but I am not able to receive anything from it.
I know it is receiving the requests because I am using a tcp-sniffer (tcpview for windows).
There is my Rebol code:
>> 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
The line with "copy serv" is meant to read whatever the server is sending.
I have tried to use it after each 'insert with the same result.
There is the output from tcpview:
Local Port (3000) opened
Waiting for connections
156: Client connected; 127.0.0.1:1213
156: Connecting to Server
156: Connected to Server
156: Client to Server (17 bytes)
0000 05 00 0A 00 00 01 44 53 4E 3D 6D 79 74 65 73 74 ......DSN=mytest
0010 3B ;
156: Server to Client (18 bytes)
0000 05 00 0C 01 01 33 44 53 4E 3D 6D 79 74 65 73 74 .....3DSN=mytest
0010 0D 0A ..
156: Client to Server (29 bytes)
0000 05 00 17 00 00 02 53 45 4C 45 43 54 20 2A 20 66 ......SELECT * f
0010 72 6F 6D 20 6D 79 74 61 62 6C 65 0D 0A rom mytable..
156: Server to Client (29 bytes)
0000 05 00 17 01 01 33 53 45 4C 45 43 54 20 2A 20 66 .....3SELECT * f
0010 72 6F 6D 20 6D 79 74 61 62 6C 65 0D 0A rom mytable..
156: Client to Server (17 bytes)
0000 05 00 0B 00 00 06 46 65 74 63 68 52 65 63 6F 72 ......FetchRecor
0010 64 d
156: Server to Client (21 bytes)
0000 05 00 0F 01 01 36 00 05 48 61 72 72 79 00 06 50 .....6..Harry..P
0010 6F 74 74 65 72 otter
156: Client disconnected
156: Disconnected from Server
It is clear that dbtcp is sending data (line like 156: Server to Client (21 bytes)).
Furthermore, when using the dbtcp-client-test provided with dbtcp,
I can see the client receiving this exact data.
Something else is troubling me. It is "1213" in the line:
156: Client connected; 127.0.0.1:1213
(the number is always different for each connection).
If i use probe serv, I can see it again:
>> probe serv
make object! [
scheme: 'tcp
host: "localhost"
port-id: 3000
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: 524835
misc: [124 [] 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: 1213 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< here
remote-port: 3000
backlog: none
device: none
speed: none
data-bits: none
parity: none
stop-bits: none
rts-cts: true
user-data: none
awake: none
]
My guess is that I should use this number in some way.
But I have looked everywhere for an example without success.
Does anybody have a clue?
Regards
Patrick
The journey is the reward.
~ Chinese Proverb