Page 1 of 1

connection reffused

Posted: Sun Jul 22, 2018 2:29 pm
by LuLove
Hello! I'm trying to create a client-server application. I have a question on luasocket. I connect the socket = require ("socket") library and write the code:

function Backgammon: rand ()
   host = "localhost"
   port = 28005
   c = assert (socket.connect (host, port))
   return c: receive ()
end

The interpreter returns an error: "connection reffused".

If I write like this:

function Backgammon: rand ()
   host = "localhost"
   port = 28005
   if arg then
     host = arg [1] or host
     port = arg [2] or port
   end
   c = assert (socket.connect (host, port))
   return c: receive ()
end

The interpreter returns an error: "host of service not provided, or not know"

How to connect?

Re: connection reffused

Posted: Mon Jul 23, 2018 9:10 am
by zorg
Hi and welcome to the forums.

Have you tried "127.0.0.1" as the host?

Re: connection reffused

Posted: Mon Jul 23, 2018 2:24 pm
by Мэтю
Silly question: Are you at least running a server at this port? You only wrote the client part, which connects to a server. If no server is running on the port of your desire then the connection will be refused

Re: connection reffused

Posted: Wed Jul 25, 2018 1:59 pm
by LuLove
Мэтю wrote: Mon Jul 23, 2018 2:24 pm Silly question: Are you at least running a server at this port? You only wrote the client part, which connects to a server. If no server is running on the port of your desire then the connection will be refused
I'm sorry. Indeed, I was just trying to connect through different ports between them