1:- module(network_ssardina,
    2    [
    3        public_ip/1
    4    ]).    5
    6:- use_module(library(http/http_open)).    7:- use_module(library(socket)).    8
    9
   10public_ip(IP) :-
   11    setup_call_cleanup(
   12        http_open('http://api.ipify.org', In, []),
   13        read_string(In, _, IP),
   14        close(In)
   15    )