Create an instance of a subclass of
socket
.address-family
,type
,connect
and IPV6 are used to specify the kind of socket to create.To initialize the socket, the following keyword arguments can be used depending on
address-family
-
:internet
or:local
(or:file
as synonim)type
-
:stream
or:datagram
connect
-
:active
or:passive
- IPV6
-
ifnil
, create an IPv4 socket, otherwise an IPv6 socket.address-family
,type
andconnect:
Glossary:
- :local-host
-
a hostname designator ornil
. If non-null the socket will be bound to this address- :local-port
-
a port designator ornil
. Iflocal-host
is non-null, bind the socket to this port. Ifnil
, choose a random port- :remote-host
-
a hostname designator ornil
. If non-null the socket will be connected to this address- :remote-port
-
a port designator. Ifremote-host
is non-null, connect the socket to this port- :local-filename
-
a string ornil
. If non-null the socket will be bound to this file- :remote-filename
-
a string ornil
. If non-null the socket will be connected to this file- :backlog
-
a positive integer ornil
. Specifies the length of the incomming connection queue and can't be larger than+max-backlog-size+
. Ifnil
, default is*default-backlog-size*
- :reuse-address: a boolean(default T). set option SO_REUSEADDR if
local-host
is non-null- :keepalive
-
a boolean. set option SO_KEEPALIVE- :nodelay
-
a boolean. set option SO_NODELAY- :interface
-
a string. set option SO_BINDTODEVICE to this interface- :input-buffer-size
-
a positive integer. Create the stream input buffer of this size- :output-buffer-size
-
a positive integer. Create the stream output buffer of this size:address-family
- hostname designator: an instance of
inet-address
or any object accepted bylookup-host
. IPV6 is passed tolookup-host
as is- port designator: any object accepted by
lookup-service
:internet
:type:stream
:connect:active
:address-family
- Valid keyword args:
:local-host
,:local-port
,:remote-host
,:remote-port
,:reuse-address
,:keepalive
,:nodelay
,:input-buffer-size
and:output-buffer-size
:internet
:type:stream
:connect:passive
:address-family
- Valid keyword args:
:local-host
,:local-port
,:backlog
,:reuse-address
,:interface
and:nodelay
:internet
:type:stream
:connect:active
:address-family
- Valid keyword args:
:local-filename
,:remote-filename
,:input-buffer-size
and:output-buffer-size
:internet
:type:stream
:connect:passive
:address-family
- Valid keyword args:
:local-filename
,:remote-filename
,:backlog
and:reuse-address
:internet
:type:datagram
:address-family
- Valid keyword args:
:local-host
,:local-port
,:remote-host
,:remote-port
,:reuse-address
,:interface
and:broadcast
:local
:type:datagram
- Valid keyword args:
:local-filename
and:remote-filename
Bind
var
to a socket created by passingargs
tomake-socket
and executebody
as implicitprogn
. The socket is automatically closed upon exit.
Create a socket instance of the appropriate subclass of
socket
usingfd
. The connection type of the socket must be specified-
:active
or:passive
. The address family and type of the socket are automatically discovered usingos
functions. Buffer sizes for the new socket can also be specified usinginput-buffer-size
andoutput-buffer-size
.
Create a pair of sockets connected to each other. The socket type must be either
:stream
or:datagram
. Currently OSes can only create:local
sockets this way. Buffer sizes for the new sockets can also be specified usinginput-buffer-size
andoutput-buffer-size
.
Send the contents of
buffer
tosocket
.buffer
must be a vector that can be coerced to a (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)).start
andend
are used a bounding index onbuffer
. For disconnected datagram sockets,remote-host
andremote-port
orremote-filename
are used as destination for the data.Some flags can also be passed to sendto(2):
Returns the number of bytes sent.
:out-of-band
for receiving out-of-band data-
only for stream sockets:dont-wait
for making only the current call non-blocking:dont-route
for sending only to hosts on directly connected networks, not using gateways:confirm
for signalling progress on the link layer-
only available on Linux and only withdatagram
sockets:more
for telling the kernel that there is more data to send-
only available on Linux
Receives data from
socket
. Ifbuffer
is specifiedstart
andend
are used as bounding index. In that casebuffer
must be an array and itsarray-element-type
be either (UNSIGNED-BYTE 8) ort
. Ifbuffer
is not specified an (UNSIGNED-BYTE 8) buffer of sizesize
will be allocated.Some flags can also be passed to recvfrom(2):
The first two values returned are the buffer and the number of elements that have been copied into the buffer. For
:out-of-band
for receiving out-of-band data-
only forstream
sockets:peek
for keeping the returned data in the kernel buffers:wait-all
for waiting until the entire buffer can be filled:dont-wait
for making only the current call non-blockinginternet
datagram
sockets, two additional values are returned: the host and port of the remote peer from which the data was received. Forlocal
datagram
sockets, one additional values is returned: the filename of the remote peer from which the data was received.
Sets the local address of
socket
to ADDRESS(andport
forinternet
sockets).reuse-address
sets the SO_REUSEADDR socket option onsocket
.
Start allowing incoming connections on
socket
.backlog
specifies the maximum length of the queue of pending connections.
Returns one connection from the queue of pending connections on
socket
. Ifwait
is true, waits until a connection is received ortimeout
expires in which case returnsnil
. Ifwait
is false and there are no pending connections returnnil
.external-format
optionally specifies the external format of the new socket-
the default being that ofsocket
. Buffer sizes for the new socket can also be specified usinginput-buffer-size
andoutput-buffer-size
.
Bind
var
to a socket created by passingpassive-socket
andargs
toaccept-connection
and executebody
as implicitprogn
. The socket is automatically closed upon exit.
Connects
socket
toaddress
. Forinternet
sockets you can specify the port to connect to using keyword argumentport
. The default value ofport
is 0, which usually means letting theos
choose a random port to connect to. Forinternet
sockets, ifwait
is true and a connection cannot be established withintimeout
seconds signaliomux:poll-timeout
, but it works only with non-blocking sockets.
Disassociates
socket
from any remote address. Works only ondatagram
sockets.
Shut down all or part of a connection. If
read
it non-NIL, further receptions are disallowed; ifwrite
is non-NIL, further transmissions are disallowed.close
must still be called onsocket
in order to releaseos
resources.