|
PLearn 0.1
|
#include <IPopen.h>


Public Member Functions | |
| IPopen (IPServer &server) | |
| IPopen (IPServer &server, const string &command, bool the_verbose=false) | |
| ~IPopen () | |
| int | get_socket_fd () const |
Public Attributes | |
| PStream | pipe |
Protected Member Functions | |
| void | launch (IPServer &server, const string &command) |
| full text variant: this one is interpreted like a console /bin/sh command | |
| void | establish_communication (IPServer &server) |
Protected Attributes | |
| bool | verbose |
| int | socket_fd |
| PLearn::IPopen::IPopen | ( | IPServer & | server | ) | [inline] |
Definition at line 119 of file IPopen.h.
{ establish_communication(server); };
| PLearn::IPopen::~IPopen | ( | ) |
| void PLearn::IPopen::establish_communication | ( | IPServer & | server | ) | [protected] |
Definition at line 75 of file IPopen.cc.
References PLearn::IPServer::get_address(), PLearn::IPServer::get_socket_fd(), and PLERROR.
{
int addr_len = sizeof(struct sockaddr_in);
// Wait for some client to connect
socket_fd = accept(server.get_socket_fd(),
(struct sockaddr *)server.get_address(),
#ifndef SGI
(socklen_t *)&addr_len);
#else //def SGI
&addr_len);
#endif //ndef SGI
if (socket_fd <= 0)
PLERROR("Failure to connect with client");
pipe.attach(socket_fd);
//following commented out since pipe is a PStream instead of an fstream...
//pipe.setbuf(0, 0); // Somehow this solves some problems
}

| int PLearn::IPopen::get_socket_fd | ( | ) | const [inline] |
| void PLearn::IPopen::launch | ( | IPServer & | server, |
| const string & | command | ||
| ) | [protected] |
full text variant: this one is interpreted like a console /bin/sh command
Definition at line 55 of file IPopen.cc.
References PLearn::endl().
{
if (verbose)
cout << "IPopen launches:" << endl << command << endl;
if (fork() == 0) {
// Child process
system(command.c_str());
exit(1);
}
establish_communication(server);
}

int PLearn::IPopen::socket_fd [protected] |
bool PLearn::IPopen::verbose [protected] |
1.7.4