How to create a websocket server plugin and run Photoshop API through client

Hi,
I need to know how to create a websocket server as UXP plugin being launched by photoshop. Therefore, I could use client to send message to server for executing the Photoshop API!!

UXP can’t do WS server. It can do only client.

Thanks for your replying.
So I guess I need to find another way to do this.

I try to use Socket.io to create a socket port while loading my plugin.

First question about “How to correct import or require module”:
When I tried this :
const { Server } = require(“socket.io”); -->>>Error: Module not found: “socket.io”. Parent module folder was: “./”
When I tried this :
import “@socket.io -->>>Cannot use import statement outside a module

Second question:
What if socket.io and websocket are not current support in UXP, how to open a port to do the way like my CEP extension?