Why doesn't this broadcasting code work when I test the game over two devices?

Hi Guys. I am making a LAN multiplayer game and I am working on my own custom HUD right now. Currently, I have two buttons. Create game and join game. Here is my code:

using System.Collections;
using System.Collections.Generic;
using System.Net;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;

public class NetUI : NetworkDiscovery {

    Button create;
    Button join;

	// Use this for initialization
	void Awake () {
    void CreateClick()

    void JoinClick()
    public override void OnReceivedBroadcast(string fromAddress, string data)
        NetworkManager.singleton.networkAddress = fromAddress;


Whenever I test the game with two windows running on the same device, my game works fine. A connection is set up and two players have a 1v1 match. However, whenever I test it with two different devices connected to the same network, for some reason it doesn’t work. Why does this happen and how do I fix it? Thanks.

Configure ports on the router and firewall if you have those and use the right IP address depending on whether the device is behind nat or not.