[EMAIL PROTECTED] (Ludovic Courtès) writes: > Following this discussion, I propose the following addition which > exposes the wrapping/unwrapping functions of `sockaddr' objects.
Hmm, I think your patch mixes the two ways we have to express a socket address: one way is an argument convention used by connect, bind, and sendto; the other way is a vector with the relevant data inside, as returned by accept, getsockname, getpeername, and recvfrom!. The scm_from_ and scm_to_ functions are meant to convert between a C representation and a Scheme representation of some value. Thus, one should be able to do things like scm_equal_p (OBJ, scm_from_sockaddr (scm_to_sockaddr (OBJ))) for example, and ideally get #t. Thus, I propose the following functions: - SCM scm_from_sockaddr (const struct sockaddr *addr, size_t addr_size); Return the SCM representation of ADDR, which is a vector ... - struct sockaddr *scm_to_sockaddr (SCM addr); Return a newly-allocated `sockaddr' structure that reflects ADDR, which is a SCM vector as returned by scm_from_sockaddr, scm_accept, etc. The returned structure may be freed using `free ()'. - SCM scm_make_socket_address (SCM fam, SCM address, SCM args); Construct a socket address like connect would given the three arguments and return it. - struct sockaddr *scm_c_make_socket_address (SCM fam, SCM address, SCM args); Equivalent to scm_to_sockaddr (scm_make_socket_address (...)). Also, scm_connect, scm_bind, and scm_sendto should probably be changed to accept a SCM representation of a socket address, so that you could write, for example: (connect sock (make-socket-address ...)) That change should be backwards compatible, of course, which is a little bit of pain because of the C API... Ludovic, could you update your patch if you agree? -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user