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

Showcase your libraries, tools and other projects that help your fellow love users.
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

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

Post 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?
User avatar
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

Post 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
User avatar
Nuthen224
Citizen
Posts: 50
Joined: Sun Jul 28, 2013 9:40 pm

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

Post by Nuthen224 »

I think the reason for that might be that connect doesn't get processed until the server/client update.
User avatar
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

Post by Sir_Silver »

Yeah that makes perfect sense, silly me. :P
Monster psychic cat
Prole
Posts: 4
Joined: Wed Mar 01, 2017 9:29 pm

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

Post 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
I don't use this account anymore.
User avatar
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

Post 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.
Monster psychic cat
Prole
Posts: 4
Joined: Wed Mar 01, 2017 9:29 pm

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

Post 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
I don't use this account anymore.
User avatar
Ikroth
Citizen
Posts: 79
Joined: Thu Jul 18, 2013 4:44 am

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

Post 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).
Monster psychic cat
Prole
Posts: 4
Joined: Wed Mar 01, 2017 9:29 pm

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

Post 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!
I don't use this account anymore.
User avatar
Ikroth
Citizen
Posts: 79
Joined: Thu Jul 18, 2013 4:44 am

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

Post by Ikroth »

I'm glad you were able to fix the issue. Let me know if you figure out what the original issue was.
Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests