(usocket): Portable R6RS socket library
(usocket) will be a portable socket library for R6RS implementations.
This library will provide wrapper layer of the implementation specific
socket APIs. Which means, it may not full support for some of the
functionalities from a particular implementation.
The library provides the following APIs.
(usocket? o): Returns
#tif the given o is an socket object, otherwise
(usocket-close! socket): Closes the given socket.
(usocket-shutdown! socket how): Shutdowns the given socket, the how argument must be the followings:
*usocket:shutdown-read*: Shutdowns read channel of the given socket.
*usocket:shutdown-write*: Shutdowns write channel of the given socket.
*usocket:shutdown-read&write*: Shutdowns read and write channels of the given socket.
(client-usocket? o): Return
#tif the given o is a client socket object, otherwise
(client-usocket-input-port client-socket): Return an binrary input port of the given client-socket.
(client-usocket-output-port client-socket): Return an binrary output port of the given client-socket.
(server-usocket? o): Return
#tif the given o is a server socket object, otherwise
(server-usocket-accept! server-socket): Waits until the given server-socket receives input and returns a client socket.
(make-tcp-client-usocket host service): Create a TCP client socket object which connects to the givne host on the service. The service can be an integer or string.
(make-tcp-server-usocket service): Create a TCP server socket object which accepts an input on the service. The service can be an integer or string.
(make-udp-client-usocket host service): Create a UDP client socket object which connects to the givne host on the service. The service can be an integer or string.
(make-udp-server-usocket service): Create a UDP server socket object which accepts an input on the service. The service can be an integer or string.
This library provides portable SRFI 106 implementation with the name
(usocket srfi pffi). This library provides all the interface
defined in SRFI 106 and extra
This library depends on the following libraries
Currently the following implemnetations are supported.
- Sagittarius Scheme (0.9.4 or later)
- Chez Scheme (v9.5),
makerequired, See below
- Larceny (1.3),
makerequired, See below
Platform dependent values
Some of the implemnetations supported this library requires platform
dependent values (e.g.
AF_INET). This library provides an easy way
to get those values, requires
make and C compiler. You can simply
type the following command in the project root directory:
By default, it uses
cc which is an alias of default C compiler in the
most of the platforms. If you want to change the compile for some reason,
you can do like this:
$ make CC=gcc
How to add implemnetations
The easiest way would be using the portable SRFI 106 implemnetations, which
requires to be supported by the
(psystem libc) library. See the dependencies
section and read the instruction of the dependency.
If the implemnetation supports socket, it's most of the case better to use it. In that case, there are following 2 scenarios:
(pffi srfi): This requires entire SRFI 106 procedures.
(pffi api): This requires implementing the following 4 procedures
lib/usocket/api.slsas an example.
Copyright and lincence
Copyright 2018 Takashi Kato. Code released under the BSD-style license. See COPYING.