• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

SWI-Prolog HTTP support
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • Introduction
        • The HTTP client libraries
        • The HTTP server libraries
        • HTTP and IPv6
        • Transfer encodings
        • library(http/websocket): WebSocket support
        • library(http/hub): Manage a hub for websockets
        • Supporting JSON
        • MIME support
        • Security
        • Tips and tricks
        • Status

4 HTTP and IPv6

As of version 9.1.5, SWI-Prolog supports IPv6. This has few implications for the HTTP package because most aspects are handled by library(socket) and library(uri). This sections highlights a few aspects.

The client libraries use http_open/3, which in turn uses tcp_connect/3. This causes the client to use addresses returned by host_address/3, which is based on the C API getaddrinfo(), in the order provided by getaddrinfo(). The URL is parsed using library(uri), which allows enclosing IPv6 addresses in []. The query below accesses an IPv6 server on localhost at port 8080

?- http_open('http://[::1]:8080', Stream, []).

The predicate http_server/2 can be used to create an IPv6 server using one of the queries below. The first binds to all interfaces. The second only binds to the IPv6 equivalent of localhost. Note that the IPv6 address needs to be quoted to create the desired Host:Port term.

?- http_server('::':8080, []).
?- http_server('::1':8080, []).

ClioPatria (version V3.1.1-51-ga0b30a5)