Why?
Frank D. Engel, Jr.
fde101 at fjrhome.net
Tue Oct 5 09:37:24 EDT 2004
Okay, so I got tired of waiting for RevDB to be fixed for PostgreSQL
(or for some explanation of how to set it up, in case my drivers are
not correctly positioned), so I am trying to write my own,
Transcript-native PostgreSQL driver for Rev (with its own API, by means
of a 'start using' command...) Never tried this before, but I did get
the 'start using' to work.
I *think* I was able to get sockets working, too, but for some reason,
at least under OS X, I cannot seem to read from a socket. What am I
doing wrong here? I have the following handler in my code:
function pgFetchMessage
read from socket pg_sock for 5
put it into x
put (charToNum(char 2 of x) * 16777216) + (charToNum(char 3 of x) *
65536) + (charToNum(char 4 of x) * 256) + charToNum(char 5 of x) \
into l
read from socket pg_sock for l
put it into z
answer charToNum(the first char of x) titled (pg_sock) && (the length
of x)
return (x & z)
end pgFetchMessage
The "answer" line results in the following title bar (empty message):
localhost:5432 0
Why would this happen? That "0" means that the length of string "x"
(which should contain exactly five characters, right?) is zero. In
other words, that string is empty -- but it shouldn't be!
Somehow I was able to get it to register a message with the letter "O"
out in front, when I was expecting to get an "R" from the server. I
went over the protocol docs to figure out what would cause a message
starting with "O", and there was no message starting with "O" in the
docs. Strange...
I am reasonably convinced (given the handler below) that I am not
getting a socketError (the "err!" box never shows up; pg_wantsock
contains the same text as pg_sock by now):
on socketError sock, errmsg
if sock is pg_wantsock then
put empty into pg_sock
put errmsg into pg_err
end if
answer "err!" & errmsg
end socketError
So what could be happening?
-----------------------------------------------------------
Frank D. Engel, Jr. <fde101 at fjrhome.net>
$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten
Son, that whosoever believeth in him should not perish, but have
everlasting life.
$
More information about the use-livecode
mailing list