A function for checking local port availability

This local-only function has the additional check of establishing
a listening socket on the intended port to check availability, which
is destroyed as soon as it is in listening status.

This solved  an issue I was having where a port established by SSH was being returned as 'open' by portscanner, i.e:

```
root     43716     1  0 Nov06 ?        00:00:00 ssh -L 0.0.0.0:35005:192.168.3.218:4101 -f stackato@localhost -N -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 

```