Next: , Previous: , Up: Networking Support   [Contents][Index]


10.7 Unbound Sockets

These functions create unbound sockets. This is usually not necessary, since connectors and listeners create their own.

Function: extensions:create-unix-socket &optional type

Creates a unix socket for the unix address family, of type :stream and (on success) returns its file descriptor.

Function: extensions:create-inet-socket &optional kind

Creates a unix socket for the internet address family, of type :stream and (on success) returns its file descriptor.

Once a socket is created, it is sometimes useful to bind the socket to a local address using bind-inet-socket:

Function: extensions:bind-inet-socket socket host port

Bind the socket to a local interface address specified by host and port.

Further, it is desirable to be able to change socket options. This is performed by the following two functions, which are essentially wrappers for system calls to getsockopt and setsockopt.

Function: extensions:get-socket-option socket level optname

Gets the value of option optname from the socket socket.

Function: extensions:set-socket-option socket level optname optval

Sets the value of option optname from the socket socket to the value optval.

For information on possible options and values we refer to the manpages of getsockopt and setsockopt, and to socket.h.

Finally, the function

Function: extensions:close-socket socket

Closes the socket given by the file descriptor socket.