Now that we have found a way to make a Gambit-internal port of OS file descriptors, how about the other way around, i.e.,
a) How get file descriptor values of active Gambit-internal TCP socket connection ports? b) Is there a way to make Gambit never make any read operations on a file descriptor / socket? (Currently, I suppose it simply does not, before one invokes a port read procedure from Scheme. Perhaps one would have to tweak the read buffering-related settings on port creation.)
Thanks Mikael
2008/9/3 Christian Jaeger christian@pflanze.mine.nu
P.S. I've now reworded the description in the file a bit to make the intent clearer. I'm attaching the diff and the files here to make sure they stay available in the archive and since the diff would only be seen when actually using the Git checkout.
Maybe Mikael could confirm some time whether this solution was what he needed and whether it worked.
Christian.
Afficher les réponses par date
Mikael More wrote:
Now that we have found a way to make a Gambit-internal port of OS file descriptors, how about the other way around, i.e.,
a) How get file descriptor values of active Gambit-internal TCP socket connection ports?
I don't have an answer, but Gambit is handling the lowlevel stuff in C code (lib/os_io.c), and it seems the filehandle (either a stdio stream or an fd) in C structs, as can also be seen when inspecting the port structure. For inspecting random Scheme objects, I've written a helper library here which turns objects to a sexpr based representation so that you can see it more easily. It also detects cycles (it will output a <seen> sexpr in that case).
http://scheme.mine.nu/gambit/experimental/object-to-sexpr/ git clone http://scheme.mine.nu/gambit/experimental/object-to-sexpr/.git
Using this you'll for example see (for an output-only port in this case):
... (rdevice-condvar #f) (wdevice-condvar (<structure> (value: #<condition-variable #51 #<foreign #52 0x6a0ea0>>) (type-chain: (#<type #53 condition-variable>)) (btq-deq-next (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-deq-prev (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-color (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-parent (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-left (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-leftmost (<seen> #<condition-variable #51 #<foreign #52 0x6a0ea0>>)) (btq-owner 2) (name #<foreign #52 0x6a0ea0>) (specific #!void)))
and it seems Gambit accesses the filehandle from that foreign object. I haven't looked at the code yet how it gets to it (and won't have time today).
Christian.