Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Using StartProcess with ping
Using StartProcess with ping [message #15620] Thu, 01 May 2008 16:58 Go to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I'm trying to use StartProcess with the ping command and not having any luck.
int Ping(){
  String cmdline = "ping -n 3 192.168.0.1";
  One<SlaveProcess> sp = StartProcess(cmdline);
  while(sp->IsRunning()){
    Sleep(200);
  }
  return sp->GetExitCode();
}


But it doesn't seem to run the ping command. Interestingly, it always returns true for the sp->IsRunning() call.

Any suggestions?
Re: Using StartProcess with ping [message #15621 is a reply to message #15620] Thu, 01 May 2008 17:39 Go to previous message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Found out through some testing that I had to call the Read() method during the loop in order to have the SlaveProcess recognize that it was finished.
int Ping(){
  String ret;  // <-- Added this line
  String cmdline = "ping -n 3 192.168.0.1";
  One<SlaveProcess> sp = StartProcess(cmdline);
  while(sp->IsRunning()){
    Sleep(200);
    sp->Read(ret); // <-- Added this line
  }
  return sp->GetExitCode();
}


This works now.
Previous Topic: Get list of open files.
Next Topic: ImageCtrl issue
Goto Forum:
  


Current Time: Fri Mar 29 16:31:27 CET 2024

Total time taken to generate the page: 0.01378 seconds