PLearn 0.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
PLearn::IPopen Class Reference

#include <IPopen.h>

Inheritance diagram for PLearn::IPopen:
Inheritance graph
[legend]
Collaboration diagram for PLearn::IPopen:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Definition at line 113 of file IPopen.h.


Constructor & Destructor Documentation

PLearn::IPopen::IPopen ( IPServer server) [inline]

Definition at line 119 of file IPopen.h.

    { establish_communication(server); };
PLearn::IPopen::IPopen ( IPServer server,
const string &  command,
bool  the_verbose = false 
) [inline]

Definition at line 121 of file IPopen.h.

    { verbose = the_verbose; launch(server, command); }        
PLearn::IPopen::~IPopen ( )

Definition at line 67 of file IPopen.cc.

                {
    //pipe.close(); // Not strictly necessary
    shutdown(socket_fd, 2);
    close(socket_fd);
}

Member Function Documentation

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
}

Here is the call graph for this function:

int PLearn::IPopen::get_socket_fd ( ) const [inline]

Definition at line 125 of file IPopen.h.

{ return socket_fd; };
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);
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 116 of file IPopen.h.

Definition at line 134 of file IPopen.h.

Definition at line 133 of file IPopen.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines