You can access a port via TCP / UDP from a web application

It is possible to send data to a port (ex: 5151) via TCP or UDP from a website, on the front end, using JavaScript for example.

I've been researching for a while and the closest I've come so far is to create a chrome App using the sockets API but I had two problems with it.

1st to use the API sockets needs to be an App instead of an extension, so it needs to be run, which is impractical for the end user.

2º is that I could not send any kind of information to him from the page, nothing, not even a "hello world".

Author: Maniero, 2020-07-14

1 answers

In general, in a real web application, running in a standard browser, there is no way to do it directly.

It is possible to use certain tricks like WebSockets that encapsulate TCP within HTTP, which obviously loses the main advantage of TCP over HTTP to be more efficient, so you make it work for compatibility reasons or because you need some feature that TCP has, such as connection State maintenance, but it is not pure TCP. And it will not be by the desired port, it will be at Port 80.

If you use a non-standard browser or some plugin you can use these protocols directly, but in general it will not be what you want, it should not make much sense.

Depending on what you want, you must abandon web technology, or else settle for this limitation.

 4
Author: Maniero, 2020-08-15 09:26:31