connection reffused

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
LuLove
Prole
Posts: 2
Joined: Sun Jul 22, 2018 2:18 pm

connection reffused

Post by LuLove » Sun Jul 22, 2018 2:29 pm

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?

User avatar
zorg
Party member
Posts: 2732
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: connection reffused

Post by zorg » Mon Jul 23, 2018 9:10 am

Hi and welcome to the forums.

Have you tried "127.0.0.1" as the host?
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
Мэтю
Prole
Posts: 31
Joined: Mon Jan 06, 2014 1:24 pm
Location: Espírito Santo, Brazil
Contact:

Re: connection reffused

Post by Мэтю » 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
World needs love.

LuLove
Prole
Posts: 2
Joined: Sun Jul 22, 2018 2:18 pm

Re: connection reffused

Post by LuLove » Wed Jul 25, 2018 1:59 pm

Мэтю 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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests