Hi Petar,
This method requires root permissions on Linux to access /proc/*/fd/
*, similar to the 'p' switch in the netstat command:
% netstat -nltp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
On AIX, you don't need to run as root, but will need read access to /
dev/kmem. You can just add yourself to the system group for example.
There is no Solaris impl yet, what version(s) are you using? I gave
up doing this on Solaris 8 a couple of years ago, but have been
planning to revisit Solaris 10 since OpenSolaris was released.
On Mar 20, 2007, at 9:14 AM, Petar Petrov wrote:
> Hi,
>
> I've tried the following code on both Fedora Core 4 and SUSE 10.2
> and it aways returns 0. It works OK on Windows (the process which
> listens on port 6500 is running on all three machines):
>
> Sigar sigar = new Sigar();
> sigar.getProcPort( "tcp", Long.toString( 6500 ) );
>
> Any help will be greatly appreciated.
> What I'm trying to do is check if a given process is running on a
> given port. Any other way to do that in Java will also help (I need
> it to work on Linux, Solaris, Windows and AIX).
>
> Thanks.
>
>
|