cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : UNIX/Linux Programming : calling netstat through a C++ code
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

post  calling netstat through a C++ code

ronan40060 (1)
Hi all

In oder to catch the SOAP Server thread running in backgroun in CLOSE_WAIT state , Im writing a code to execute the netstat within my server code
I understand that popen is better than system() as o/p of system() cant be stored.
I have the following code snipette that uses popen
FILE * count ;
char buff[1024];
if (!(count =popen("netstat -an | grep -i 6071 | grep CLOSE_WAIT")))
{
PRINT(" NO SOAP HUNG THREAD FOUND ");
}
while(fgets(buff, sizeof(buff), in) != NULL )
{
PRINT("\n ... SOAP Server HUNG Thread found");
}

Can someone please let me know if above code can be improved better ?
Thanks
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us