Changed connection function to use SwiProlog's
connection uses swiprolog socket functions