On Linux using MONO.
How do I use C# to pair a port number to a service ?
example:
port 80 = http
port 443 = https
and output it to the console, I need this for a simple port scanner I built.
I know this function exists in ruby:
Socket.getservbyport(80, "tcp")
Mono Linux version
I had a bit of time on my hands so set up Mono on my Ubuntu Linux box to test with. The Mono PInvoke implementation of getservbyport() and getservbyname() is simpler than on Windows (just load libc which has the networking stuff built in). Here’s the example code for reference in case anyone ever wants it 😉