DefNet P2P Discovery Issue [Solved]

I’m right now trying to make a LAN multiplayer games using DefNet. I found out that DefNet is exactly what I need to make a simple multiplayer game from 2 to 4 players. My plan is to use the p2p discovery to let others to detect a host machine, then other can connect to the host machine using the ip address that it provides using TCP socket. But I found some issues when trying the examples:

  1. I’ve tested p2p discovery and found out that only the first machine discover the host can receive the data, when I ran the 2nd and the 3rd ones, it just kept listening without discovering the host.
  2. When I open 2 instances (I’m gonna call it [instance1] and [instance2]), I use [intance1] to broadcast and [instance2] to listen, everything is working fine. But when I get back to the main menu and get back again to change to [instance2] to broadcast and [instance1] to listen, it doesn’t work anymore.

I’m a newbie to networking, so maybe there’s something to twist to make it works but I don’t know yet, or this is the way DefNet P2P Discovery works?

Edit: So I’ve found out that when you testing, if it’s more than 2 instances, you should test it in other machines if you want to use P2P_Discovery.

It should be possible for the “host” instance to broadcast and be discovered by multiple “clients”. Are you sure that you’re not stopping the p2p broadcast when the first client has connected with the broadcasting host?

Yes, I’m sure about that. Another thing that I forgot to mention is that right now I’m just testing on my own laptop only, is it gonna be the case?

I have a screen record for what I’ve tested here. Can you take a look?

Hi, I’ve tested with other machines, and yes, it works really well. So yes, it should be testing in different machines if you want to test from 3 or more instances. Other than that, other examples are working really well.

I think this should be noted down on the documentation for others who want to test the examples or test their games using 3 or more instances.

Anyway, thank you for spending your time in here, and thank you for the extension, it’s absolutely great especially for beginner like me.

Good point. I added a note in the documentation/readme.

Happy to hear that!

1 Like

Hi @britzl ,
I’ve found out that the p2p discovery example on DefNet had an issue:

  • The self.p2p.listen doesn’t stop after it finds a host, and I just found out that the new version has a breaking change to have a ability to do so.

That’s why on the example, after found out a server, the logo is just flying up instead of playing the animation. So my suggestion is to fix this one in the example, or maybe you can add an optional button to trigger whether or not there should be a stop after found out a server, so people can see what happen when they use the stop in the self.p2p.listen.

Sure, please create a ticket on GitHub and I’ll see what can be improved!

1 Like

Thanks @britzl, I’ve posted an issue in the github page, please check it out.

1 Like