Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: Network Sockets and Communication, Previous: Network Databases, Up: Networking [Contents][Index]
A socket address object identifies a socket endpoint for
communication. In the case of AF_INET
for instance, the socket
address object comprises the host address (or interface on the host)
and a port number which specifies a particular open socket in a
running client or server process. A socket address object can be
created with,
Return a new socket address object. The first argument is the address
family, one of the AF
constants, then the arguments vary
according to the family.
For AF_INET
the arguments are an IPv4 network address number
(see Network Address Conversion), and a port number.
For AF_INET6
the arguments are an IPv6 network address number
and a port number. Optional flowinfo and scopeid
arguments may be given (both integers, default 0).
For AF_UNIX
the argument is a filename (a string).
The C function scm_make_socket_address
takes the family
and address arguments directly, then arglist is a list of
further arguments, being the port for IPv4, port and optional flowinfo
and scopeid for IPv6, or the empty list SCM_EOL
for Unix
domain.
The following functions access the fields of a socket address object,
Return the address family from socket address object sa. This
is one of the AF
constants (e.g. AF_INET
).
For an AF_UNIX
socket address object sa, return the
filename.
For an AF_INET
or AF_INET6
socket address object
sa, return the network address number.
For an AF_INET
or AF_INET6
socket address object
sa, return the port number.
For an AF_INET6
socket address object sa, return the
flowinfo value.
For an AF_INET6
socket address object sa, return the
scope ID value.
The functions below convert to and from the C struct sockaddr
(see Address Formats in The GNU C Library Reference Manual).
That structure is a generic type, an application can cast to or from
struct sockaddr_in
, struct sockaddr_in6
or struct
sockaddr_un
according to the address family.
In a struct sockaddr
taken or returned, the byte ordering in
the fields follows the C conventions (see Byte Order
Conversion in The GNU C Library Reference Manual). This means
network byte order for AF_INET
host address
(sin_addr.s_addr
) and port number (sin_port
), and
AF_INET6
port number (sin6_port
). But at the Scheme
level these values are taken or returned in host byte order, so the
port is an ordinary integer, and the host address likewise is an
ordinary integer (as described in Network Address Conversion).
Return a newly-malloc
ed struct sockaddr
created from
arguments like those taken by scm_make_socket_address
above.
The size (in bytes) of the struct sockaddr
return is stored
into *outsize
. An application must call free
to
release the returned structure when no longer required.
Return a Scheme socket address object from the C address structure. address_size is the size in bytes of address.
Return a newly-malloc
ed struct sockaddr
from a Scheme
level socket address object.
The size (in bytes) of the struct sockaddr
return is stored
into *outsize
. An application must call free
to
release the returned structure when no longer required.
Next: Network Sockets and Communication, Previous: Network Databases, Up: Networking [Contents][Index]