judge if listening socket

try: getsockopt

man 7 socket #then search SO_ SO_ACCEPTCONN

See also:

net-tools-1.60/netstat.c