'Get connected Port

I want to build a program that will run on my Raspberry Pi and starts processes when I connect to it. I want to run a specific processes if there is a connection on a specific port.

So I need to get the port somebody is trying to connect to.

For example: If I open localhost:4444 in my browser I want to get 4444 as a string or an int.

It doesn’t need to be C#. Would be great, but it can also be in other languages.

Is this possible and how can I achieve that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source