Socket ports can be created using socket
and socketpair
.
The ports are initially unbuffered, to
makes reading and writing to the same port more reliable. Buffered
ports can be obtained with
duplicate-port
, See section Ports and File Descriptors.
These procedures convert Internet addresses and port values between "host" order and "network" order as required. The arguments and return values should be in "host" order.
AF_UNIX
and AF_INET
. Typical values for style are
the values of SOCK_STREAM
, SOCK_DGRAM
and SOCK_RAW
.
protocol can be obtained from a protocol name using
getprotobyname
. A value of
zero specifies the default protocol, which is usually right.
A single socket port cannot by used for communication until it has been connected to another socket.
AF_UNIX
family. Zero is likely to be
the only meaningful value for protocol.
SOL_SOCKET
for socket-level options.
optname is an
integer code for the option required and should be specified using one of
the symbols SO_DEBUG
, SO_REUSEADDR
etc.
The returned value is typically an integer but SO_LINGER
returns a
pair of integers.
SOL_SOCKET
for socket-level options.
optname is an
integer code for the option to set and should be specified using one of
the symbols SO_DEBUG
, SO_REUSEADDR
etc.
value is the value to which the option should be set. For
most options this must be an integer, but for SO_LINGER
it must
be a pair.
The return value is unspecified.
close-port
. The
shutdown
procedure allows reception or tranmission on a
connection to be shut down individually, according to the parameter
how:
The return value is unspecified.
For a socket of family AF_UNIX
,
only address
is specified and must be a string with the
filename where the socket is to be created.
For a socket of family AF_INET
,
address
must be an integer Internet host address and arg ...
must be a single integer port number.
The return value is unspecified.
The format of address and ARG ... depends on the family of the socket.
For a socket of family AF_UNIX
, only address
is specified and must
be a string with the filename where the socket is to be created.
For a socket of family AF_INET
, address must be an integer
Internet host address and arg ... must be a single integer
port number.
The values of the following variables can also be used for address:
The return value is unspecified.
accept
to accept a connection from the queue.
The return value is unspecified.
The return value is a pair in which the CAR is a new socket port for the connection and the CDR is an object with address information about the client which initiated the connection.
If the address is not available then the CDR will be an empty vector.
socket does not become part of the connection and will continue to accept new requests.
The following functions take a socket address object, as returned
by accept
and other procedures, and return a selected component.
sockaddr:fam
AF_UNIX
or
AF_INET
.
sockaddr:path
AF_UNIX
, returns the path of the
filename the socket is based on.
sockaddr:addr
AF_INET
, returns the Internet host
address.
sockaddr:port
AF_INET
, returns the Internet port
number.
accept
. On many systems the address of a socket
in the AF_FILE
namespace cannot be read.
accept
. On many systems the address of a socket
in the AF_FILE
namespace cannot be read.
The optional flags argument is a value or bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
The value returned is the number of bytes read from the socket.
Note that the data is read directly from the socket file descriptor: any unread buffered port data is ignored.
Note that the data is written directly to the socket file descriptor: any unflushed buffered port data is ignored.
buf
, is a string into which
the data will be written. The size of buf limits the amount of
data which can be received: in the case of packet
protocols, if a packet larger than this limit is encountered then some data
will be irrevocably lost.
The optional flags argument is a value or bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
The value returned is a pair: the CAR is the number of bytes read from
the socket and the CDR an address object in the same form as returned by
accept
.
The start and end arguments specify a substring of buf to which the data should be written.
Note that the data is read directly from the socket file descriptor: any unread buffered port data is ignored.
connect
procedure. The
value returned is the number of bytes transmitted -- it's possible for
this to be less than the length of message if the socket is
set to be non-blocking. The optional flags argument is a value or
bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc.
Note that the data is written directly to the socket file descriptor: any unflushed buffered port data is ignored.
Go to the first, previous, next, last section, table of contents.