Create and return a new addrinfo structure for the given host
and service. host
should be a string and service
a
string or integer. The optional addrinfo
defaults to
a TCP/IP stream setting.
Opens a client net connection to host
, a string,
on port service
, which can be a string such as
"http"
or an integer. Returns a list of three
values on success - the socket, an input port, and an
output port - or #f
on failure.
Convenience wrapper around open-net-io
, opens
the connection then calls proc
with two arguments,
the input port and the output port connected to the
service, then closes the connection. Returns the result
of proc
. Raises an error if a connection can't
be made.
Convenience wrapper to call socket, bind and listen to return
a socket suitable for accepting connections on the given
addrinfo
. max-conn
is the maximum number of pending
connections, and defaults to 128. Automatically specifies
socket-opt/reuseaddr
.
Returns the socket option of the given name
for socket
.
socket
should be a file descriptor, level the constant
level/socket
, and name one of the constants beginning with
"socket-opt/".
Sends the bytevector bv
to socket
with sendto and
returns the number of bytes sent, or a negative value on error.
If addrinfo
is unspecified, socket
must previously
have had a default address specified with connect
.
Equivalent to send
but gives up and returns false if the
packet can't be sent within timeout
seconds.
Recieves data from socket
to fill the bytevector bv
by
calling recvfrom. Returns the number of bytes read, or a negative
value on error. If addrinfo
is unspecified, socket
must previously have had a default address specified with
connect
.
Equivalent to receive!
but gives up and returns false if
no packets are received within timeout
seconds.
Shortcut for receive
, returning a newly created
bytevector of length n
on success and #f
on
failure.
Equivalent to receive
but gives up and returns false if
no packets are received within timeout
seconds.
(address-info? obj)
(address-info-family addrinfo)
(address-info-socket-type addrinfo)
(address-info-protocol addrinfo)
(address-info-flags addrinfo)
(address-info-address addrinfo)
(address-info-address-length addrinfo)
(address-info-canonname addrinfo)
(address-info-next addrinfo)
(address-info-family addrinfo)
(address-info-socket-type addrinfo)
(address-info-protocol addrinfo)
(address-info-flags addrinfo)
(address-info-address addrinfo)
(address-info-address-length addrinfo)
(address-info-canonname addrinfo)
(address-info-next addrinfo)
The addrinfo struct accessors.
Bind a name to a socket.
Listen on a socket.
Accept a connection on a socket.
Create an endpoint for communication.
Initiate a connection on a socket.
Returns a list of 2 new sockets, the input and output end of a new pipe, respectively.
Return the IP address of a sockaddr as an "N.N.N.N" string.
Return the port a sockaddr is connected on.
The constants for the addrinfo struct.
Set an option for the given socket. For example, to make the
address reusable:
(set-socket-option! sock level/socket socket-opt/reuseaddr 1)
The constants for the get-socket-option
and
set-socket-option!
.