Page 4 of 9

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

Posted: Sun Mar 19, 2017 4:56 am
by BorhilIan
My only question is how is this libraries binary performance? To reiterate how much overhead to each packet is there, can it be used to send/receive unsigned integers of varying bit or byte length?

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

Posted: Sat Jun 03, 2017 11:07 am
by Sir_Silver
I've been working on making something with your library and I'm having some issues with the disconnect event. It doesn't seem to be getting called on the client or server, even though I have callbacks defined for both client and server, when I have a client disconnect. I'm gonna check the source code, but I'm guessing that disconnect doesn't actually get called when a client disconnects?

Edit: It actually does work, it just seems that I needed to add a timer between connecting and disconnecting, so I guess I can't just connect and disconnect in the same frame. :P problem solved

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

Posted: Sun Jun 04, 2017 12:39 am
by Nuthen224
I think the reason for that might be that connect doesn't get processed until the server/client update.

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

Posted: Sun Jun 04, 2017 12:52 am
by Sir_Silver
Yeah that makes perfect sense, silly me. :P

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

Posted: Fri Jun 09, 2017 1:22 am
by Monster psychic cat
Hello there.
I've been staring at my code in a text editor for hours trying to understand what I'm doing wrong. I keep getting a "Error during service" error (sock.lua - line 721), and tracing back doesn't tell me much.

My code (hope I'm not doing something dumb):

Code: Select all

-- client
local sock = require "sock"
local address, port = "localhost", 12345
local cnet = sock.newClient(address, port, 2)

-- connection callback
cnet:on("connect", function(data, client)
    print("connecting...")
end)

-- custom callback
cnet:on("hello", function(msg)
    print("what's this? " .. msg)
end)

function love.update(dt)
    cnet:update()
end

Code: Select all

-- server (doesn't run on LÖVE)
local sock = require "sock"
local snet = sock.newServer("*", 12345, 8, 2)

snet:on("connect", function(data, client)
    client:send("hello", "oh hey!")
end)

while true do
    snet:update()
end

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

Posted: Fri Jun 09, 2017 4:48 am
by Sir_Silver
The reason you're getting that error is because you haven't actually connected the client to the server. Call cnet:connect() at the end of your client file.

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

Posted: Fri Jun 09, 2017 10:22 pm
by Monster psychic cat
Sir_Silver wrote: Fri Jun 09, 2017 4:48 am The reason you're getting that error is because you haven't actually connected the client to the server. Call cnet:connect() at the end of your client file.
I have done that... and it's still giving me a error.
Image

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

Posted: Sat Jun 10, 2017 12:35 am
by Ikroth
It may help to post more of your code. I don't see anything obviously wrong with the screenshot that you posted. "Error during service" is just enet's generic error message that doesn't return any more information than the message itself. I would check a couple of things to just make sure its working: use an IPv4 address, make sure both the client and server have bitser (or some other serialization library) and are using it, and make sure that server was actually bound to the port (using something like netstat).

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

Posted: Sat Jun 10, 2017 1:14 am
by Monster psychic cat
Apparently, rewriting the code from scratch just to make a new .love file to test didn't bring up the crash anymore - and just using that code in my main game fixed it?????????????

In turn, I lost all of my previous networking code. However, I was already planning to rewrite my code. Thanks anyway!

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

Posted: Sat Jun 10, 2017 1:22 am
by Ikroth
I'm glad you were able to fix the issue. Let me know if you figure out what the original issue was.