<div dir="ltr">Rob, I don't know if this contributes to answering your question but,<div>(1) you can get the OS FD:s out of the Gambit TCP server and client ports,</div><div>(2) note that (at least the client) ports' FD:s are set up in asynchronous mode at the level of OS FD so your reads & writes will be nonblocking unless you change that setting and supposedly you don't want to do that, and</div>

<div>(3) you can have Gambit do typical select() work for you on port objects using the ##wait-for-input! & -output! procedures i.e. your Gambit and C code can cooperate this way i.e. Gambit code waits for FD readiness and then your C code does the IO. Last,</div>

<div>(4) there's some procedure in Gambit to import an OS FD and make a port object out of it.<div>Mikael<div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-07 23:32 GMT+02:00 Rob Kellock <span dir="ltr"><<a href="mailto:sales@creditscore.co.nz" target="_blank">sales@creditscore.co.nz</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Quite some time ago I managed to successfully interface with a C library<br>
using FFI.  Now I'm having another go, but this time I want to connect<br>
to it using native Scheme code.  The C library is the interface to a<br>
select based TCP socket server, so I figure I should be able to connect<br>
to it directly using open-tcp-client and forgo the whole FFI thing.<br>
<br>
The way the C library works is that a C struct is sent to the receiving<br>
socket first so that it knows the length of the message buffer that will<br>
follow and some other information specific to the socket server's<br>
operation. This is immediately followed up by the message buffer which<br>
is in binary format.<br>
<br>
So far... I think I've managed to work out that I should be using<br>
u8vector data structure for both the C struct and the message buffer,<br>
although I don't yet understand what kind of encoding is going on in<br>
there. That will come after I've looked at some examples.<br>
<br>
My plan is to extend the existing web-server.scm example to produce a<br>
web app that talks to it's relational database using native Scheme. I'm<br>
going down this route because I want to extend web-server.scm using the<br>
GSI.  If I use the FFI I'm restricted to the GSC which prevents the<br>
whole interactive development scenario I want where I can keep the<br>
browser running, the database running and just stop and start the GSI as<br>
I hack code.<br>
<br>
What I want to know first though is if I use open-tcp-client inside<br>
Gambit's threads will the native Scheme calls out to the external socket<br>
server block?  If they don't then am I on the right track to use u8vector?<br>
<br>
Thanks,<br>
<br>
Rob.<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</blockquote></div><br></div>