[plt-scheme] FFI + errno

From: Steve Huffman (steve.huffman at gmail.com)
Date: Mon Dec 7 18:18:27 EST 2009

Hi All,

I'm using OS X and trying to access the raw socket api using PLT's
FFI. For example:

(define _socket
  (get-ffi-obj "socket" #f (_fun _int _int _int -> _int)))

(define _connect
  (get-ffi-obj "connect" #f (_fun _int _sockaddr_in-pointer _int -> _int)))

Things are mostly working, except I'm having trouble accessing the
global errno value to see error codes. I've tried wrapping the
__error() function, but am not receive relevant error codes.

I gather from searching this list that PLT itself might be using errno
for its own purposes before I get a chance to see it. Is that

Should I write my own wrapper functions in C around the socket
functions and capture/store errno someplace else?



Posted on the users mailing list.