guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Socket API improvement, patch #6


From: Ludovic Courtès
Subject: Re: Socket API improvement, patch #6
Date: Thu, 27 Oct 2005 10:49:53 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Hi,

Kevin Ryde <address@hidden> writes:

> Ok, we got there eventually.  I checked it in, and I updated the docs
> (have a read to see it they look right).

Great, thanks!

The doc looks good to me.  I'd just suggest the following patch.  It
documents the wrapping/unwrapping C functions (since that was my
original goal).

Thanks,
Ludovic.


--- orig/doc/ref/posix.texi
+++ mod/doc/ref/posix.texi
@@ -2449,18 +2449,20 @@
 @subsubsection Network Socket Address
 @cindex socket
 @cindex network socket
address@hidden socket address
 
-A socket address object identifies a socket endpoint for
-communication.  In the case of @code{AF_INET} for instance, the host
-address is only the machine (or interface on the machine), a port
-number is also needed to specify a particular open socket in a running
+A @dfn{socket address} object identifies a socket endpoint for
+communication.  In the case of @code{AF_INET} for instance, the socket
+address object comprises the machine (or interface on the machine) and
+a port number needed to specify a particular open socket in a running
 client or server process.
 
 A socket address object can be created with,
 
address@hidden {Scheme Procedure} make-socket-address AF_INET ipv4addr port
address@hidden {Scheme Procedure} make-socket-address AF_INET6 ipv6addr port 
[flowinfo [scopeid]]
address@hidden {Scheme Procedure} make-socket-address AF_UNIX path
address@hidden {Scheme Procedure} make-socket-address AF_INET ipv4addr port
address@hidden {Scheme Procedure} make-socket-address AF_INET6 ipv6addr port 
[flowinfo [scopeid]]
address@hidden {Scheme Procedure} make-socket-address AF_UNIX path
address@hidden {C Function} scm_make_socket_address family address args
 Return a new socket address object.  The first argument is the address
 family, one of the @code{AF} constants, then the arguments vary
 according to the family.
@@ -2473,7 +2475,7 @@
 arguments may be given (both integers, default 0).
 
 For @code{AF_UNIX} the argument is a filename (a string).
address@hidden defun
address@hidden deffn
 
 @noindent
 The following functions access the fields of a socket address object,
@@ -2508,6 +2510,34 @@
 scope ID value.
 @end deffn
 
+Guile also defines C functions to manipulate socket address objects
+and to convert them from/to their C representation (a @code{struct
+sockaddr} object) to/from their Scheme representation.
+
address@hidden {C Function} {struct sockaddr *}scm_c_make_socket_address (SCM 
family, SCM address, SCM args, size_t *address_size)
+Return a newly-allocated @code{sockaddr} structure that reflects
address@hidden, an address of family @var{family}, with the
+family-specific parameters @var{args} (see the description of
address@hidden for details).  On success, a address@hidden
+pointer is returned and @var{address_size} is updated to the actual
+size (in bytes) of the returned address.  The returned structure must
+eventually be freed using @code{free ()}.
address@hidden deftypefn
+
address@hidden {C Function} SCM scm_from_sockaddr (const struct sockaddr 
*address, unsigned address_size)
+Return the Scheme object representing @var{address}, a C socket
+address object of size @var{address_size} bytes.
address@hidden deftypefn
+
address@hidden {C Function} {struct sockaddr *}scm_to_sockaddr (SCM address, 
size_t *address_size)
+Return a newly-allocated @code{sockaddr} structure that reflects
address@hidden, an address object returned by either
address@hidden ()} or @code{scm_make_socket_address ()}, into
+its C representation.  On success, a address@hidden pointer is
+returned and @var{address_size} is updated to the actual size (in
+bytes) of the returned address.  The returned value must eventually be
+freed using @code{free ()}.
address@hidden deftypefn
 
 @node Network Sockets and Communication
 @subsubsection Network Sockets and Communication





reply via email to

[Prev in Thread] Current Thread [Next in Thread]