Is there a way to do it without calling external utilities (i.e. a Python module, etc)? I'd rather stay within the realm of Python if possible.

Jason



On 01/23/2015 10:04 AM, Chris Angelico wrote:
On Sat, Jan 24, 2015 at 3:02 AM, Jason Bailey <jbai...@emerytelcom.com> wrote:
I'm actually wondering if it might be more beneficial for me to check if the
local DHCP port (udp 67) is bound and in use. I had tried to do this some
time ago, and couldn't get it working right (it would always test true, even
when it shouldn't have). Can anyone steer me in the right direction on port
status?
You can check with netstat:

$ sudo netstat -n4lp|grep ':67 '
udp        0      0 0.0.0.0:67              0.0.0.0:*
          22466/dhcpd

On my system, there's a /proc/net/udp which carries this information.
Everything's in hex, so port 67 is shown as 0043:

$ grep :0043 /proc/net/udp
  5755: 00000000:0043 00000000:0000 07 00000000:00000000 00:00000000
00000000     0        0 8334454 2 ffff880403e60b40 0

You'd have to check your own system to know what's truly reliable and
worth using.

ChrisA


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to