hi, i want to find process pid through port, such as through 3306 got PID 
2052

# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State   
    PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN 
     2052/mysqld   

but i didn't find a package to do this, i also find some ways do this, as 
following:
1.use exec.Command to excute netstat, and then filter cmd.StdoutPipe() to 
find pid.
2.read system files, such as /proc/net/tcp, and then find pid.

Personally, i would prefer to use method two, and method one which i think 
is too heavy.

Maybe you have a better way, and look forward to your reply, thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to