From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.user Subject: Re: Exposing common type wrapping/unwrapping methods Date: Mon, 05 Sep 2005 01:09:45 +0300 Message-ID: <87fysk7ady.fsf@zagadka.de> References: <87oecutxox.fsf@laas.fr> <87vf58cxxq.fsf@zagadka.de> <87k6kwopv5.fsf@laas.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1125872595 13701 80.91.229.2 (4 Sep 2005 22:23:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 4 Sep 2005 22:23:15 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Sep 05 00:23:13 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EC2s3-0006TQ-CQ for guile-user@m.gmane.org; Mon, 05 Sep 2005 00:21:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EC2wS-0003CQ-Pc for guile-user@m.gmane.org; Sun, 04 Sep 2005 18:26:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EC2tt-0002GY-2B for guile-user@gnu.org; Sun, 04 Sep 2005 18:23:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EC2tp-0002Dy-I1 for guile-user@gnu.org; Sun, 04 Sep 2005 18:23:42 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EC2to-00026c-NW for guile-user@gnu.org; Sun, 04 Sep 2005 18:23:40 -0400 Original-Received: from [213.243.153.37] (helo=smtp1.pp.htv.fi) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EC2jx-0004YC-U6 for guile-user@gnu.org; Sun, 04 Sep 2005 18:13:30 -0400 Original-Received: from zagadka.ping.de (cs181072157.pp.htv.fi [82.181.72.157]) by smtp1.pp.htv.fi (Postfix) with SMTP id 84BC67FC51 for ; Mon, 5 Sep 2005 01:09:45 +0300 (EEST) Original-Received: (qmail 5044 invoked by uid 1000); 4 Sep 2005 22:09:45 -0000 Original-To: ludovic.courtes@laas.fr (Ludovic =?iso-8859-1?Q?Court=E8s?=) In-Reply-To: <87k6kwopv5.fsf@laas.fr> (Ludovic =?iso-8859-1?Q?Court=E8s's?= message of "Tue, 14 Jun 2005 18:38:38 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4718 Archived-At: ludovic.courtes@laas.fr (Ludovic Court=E8s) 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? --=20 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