mbvee
mbvee

Reputation: 391

How to identify port number of a desktop application(Windows and MAC) using Javascript

I have a desktop application that is running on a particular port in a Windows machine. I am now developing a chrome extension that interacts with the desktop application. I would like to know the port number on which the desktop application is running.

Is there any way how I can identify the port number of an application using javascript ? Any pointers will be really helpful.

Upvotes: 1

Views: 1497

Answers (1)

Keith
Keith

Reputation: 155692

You can use chrome.sockets.tcp to connect to a known endpoint.

You have to request the specific endpoint in the manifest in order to have permission to access it.

If the manifest allows it you could try lots of ports at that endpoint until you found one that responded with your service, but that would be sloooooooooow and incredibly bug prone.

Instead choose a specific port (or make it configurable) and just connect directly.

Upvotes: 1

Related Questions