sock.lua - A simple networking library for LÖVE
Re: sock.lua - A simple networking library for LÖVE
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?
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: sock.lua - A simple networking library for LÖVE
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. problem solved
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. problem solved
Re: sock.lua - A simple networking library for LÖVE
I think the reason for that might be that connect doesn't get processed until the server/client update.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: sock.lua - A simple networking library for LÖVE
Yeah that makes perfect sense, silly me.
-
- Prole
- Posts: 4
- Joined: Wed Mar 01, 2017 9:29 pm
Re: sock.lua - A simple networking library for LÖVE
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):
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
I don't use this account anymore.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: sock.lua - A simple networking library for LÖVE
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.
-
- Prole
- Posts: 4
- Joined: Wed Mar 01, 2017 9:29 pm
Re: sock.lua - A simple networking library for LÖVE
I have done that... and it's still giving me a error.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 don't use this account anymore.
Re: sock.lua - A simple networking library for LÖVE
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).
-
- Prole
- Posts: 4
- Joined: Wed Mar 01, 2017 9:29 pm
Re: sock.lua - A simple networking library for LÖVE
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!
In turn, I lost all of my previous networking code. However, I was already planning to rewrite my code. Thanks anyway!
I don't use this account anymore.
Re: sock.lua - A simple networking library for LÖVE
I'm glad you were able to fix the issue. Let me know if you figure out what the original issue was.
Who is online
Users browsing this forum: No registered users and 0 guests