Page 5 of 9

Re: sock.lua - A simple networking library for LÖVE

Posted: Sun Jun 11, 2017 12:21 am
by Sir_Silver
Ikroth, is it normal/expected behavior for clients to remain connected to a server after the server calls :destroy() on itself? Right now after destroying my server clients remain connected, so I''m opting to iterate through the clients on the server and have them call :disconnect().

I looked through sock.lua and found that server:destroy() calls self.host:destroy(), but host is defined as nil, is this just something that has been in the works/ just wasn't developed yet?

Thanks for your time. =)

Re: sock.lua - A simple networking library for LÖVE

Posted: Sun Jun 11, 2017 4:18 am
by Ikroth
Destroying the host just means it will immediately unbind itself from the port and trash the pointers to any resources. So yes, you would need to go through all of the clients and send them a disconnect message.

I'm not sure I'd want to automatically disconnect clients since you may want to handle it differently, like waiting until all clients acknowledge the disconnect to actually destroy the server.

Re: sock.lua - A simple networking library for LÖVE

Posted: Sun Jun 11, 2017 5:28 am
by Sir_Silver
Cool, thank you for responding. Just wanted to make sure that I wasn't doing anything too stupid :)

Re: sock.lua - A simple networking library for LÖVE

Posted: Tue Jun 13, 2017 12:06 am
by Sir_Silver
I'm having issues hosting a server using my public ip and a port that I am sure is forwarded. It gives me failed to create host error, also worth noting that I am pretty sure there isn't a server being hosted on that port. I am able to successfully host a server if I pass "*" or "localhost" to the server address though, however, if I host it with one of these addresses, I am not able to connect a client using my public ip. Do you have any suggestions or thoughts on this?

Re: sock.lua - A simple networking library for LÖVE

Posted: Tue Jun 13, 2017 10:45 pm
by Ikroth
I haven't encountered the issues you are describing so far. I would not expect binding to localhost on the server to work when connecting using the public IP address, because it is explicitly localhost only, even if the client and server are on the same computer. You have to connect with either 127.0.0.1 or localhost in that case. When hosting publicly, binding to "*" or your public IP address directly should work.

Re: sock.lua - A simple networking library for LÖVE

Posted: Wed Jun 14, 2017 12:43 am
by Sir_Silver
Oh you know I think I might not have explained this very well, I'll try it again.

I have port forwarded the port 27015, I'm sure there is not server running on that port.

On one of my servers I have this code:

Code: Select all

local server = sock.newServer(my_public_ip_here, 27015)
And it gives me the error Failed to create host, is there a server running on this port?

So my problem is hosting a server using my public ip. Works with "localhost" or "*"

Edit: So I asked my friend to host a server using the code I wrote and he is able to connect to himself using his public ip, and I can connect to him fine as well, however, I am not able to connect to myself using my public ip. I have no idea whats going on here.

Re: sock.lua - A simple networking library for LÖVE

Posted: Wed Jun 14, 2017 7:03 am
by bartbes
Did you set up your forward for tcp or udp?

Re: sock.lua - A simple networking library for LÖVE

Posted: Wed Jun 14, 2017 7:20 pm
by Sir_Silver
I believe that the ports that I've forwarded are for both tcp and udp.

Re: sock.lua - A simple networking library for LÖVE

Posted: Fri Jun 16, 2017 4:50 am
by Ikroth
What's the minimum amount of code that reproduces it? Does it break if you have a main.lua that only calls newServer?

Re: sock.lua - A simple networking library for LÖVE

Posted: Fri Jun 16, 2017 4:54 am
by Sir_Silver
Yes, the minimum amount of code needed to cause the error is this:

Code: Select all

local sock = require("lib/networking/sock")

local server = sock.newServer(my_ip_here, 27015)
where my_ip_here is a string that is my public ip address.