Check out example codes for "unity socket io". It will help you in understanding the concepts better.

Code Example 1

// Use this library, it works perfectly:
// https://github.com/dp0ch/Unity-SocketIO-Client

// Usage:
using Dpoch.SocketIO;

public class MyClass : MonoBehavior {
  public void Start {
    var socket = new SocketIO("ws://127.0.0.1:80/socket.io/?EIO=4&transport=websocket");

    socket.OnOpen += () => {
      Debug.Log("Connected!")
    };
    socket.OnConnectFailed += () => {
      Debug.Log("Connection failed.")
    };
    socket.OnClose += () => {
      Debug.Log("Connection closed.")
    };
    socket.OnError += (err) => {
      Debug.Log("Error: " + err)
    };

    socket.Connect();
  }
}

// Look into the libararies README for further documentation.

Learn ReactJs, React Native from akashmittal.com