PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions
PLearn::IPServer Class Reference

#include <IPopen.h>

Collaboration diagram for PLearn::IPServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 IPServer (int port_no, int max_connections)
 IPServer (int max_connections_)
 IPServer ()
 ~IPServer ()
int get_socket_fd ()
struct sockaddr_in * get_address ()
string machine_name ()
int port_no ()

Static Public Member Functions

static void set_ip_port (int port_no, int max_connections_=100)

Static Public Attributes

static int ip_port = 15000
static int max_connections = 100

Protected Attributes

int socket_fd
int port
struct sockaddr_in address

Private Member Functions

void DelayedConstructor (int port_no, int max_connections_)

Detailed Description

Definition at line 62 of file IPopen.h.


Constructor & Destructor Documentation

PLearn::IPServer::IPServer ( int  port_no,
int  max_connections 
) [inline]

Definition at line 64 of file IPopen.h.

                                               {
        DelayedConstructor(port_no, max_connections);
    };
PLearn::IPServer::IPServer ( int  max_connections_) [inline]

Definition at line 67 of file IPopen.h.

                                   {
        DelayedConstructor(ip_port, max_connections_);
    };
PLearn::IPServer::IPServer ( ) [inline]

Definition at line 70 of file IPopen.h.

PLearn::IPServer::~IPServer ( ) [inline]

Definition at line 73 of file IPopen.h.

                {
        shutdown(socket_fd, 2);
        close(socket_fd);
    };

Member Function Documentation

void PLearn::IPServer::DelayedConstructor ( int  port_no,
int  max_connections_ 
) [inline, private]

Definition at line 88 of file IPopen.h.

References PLERROR.

                                                               {
        port = port_no;

        int addr_len = sizeof(struct sockaddr_in);
            
        socket_fd = socket(AF_INET, SOCK_STREAM, 0);
        if (socket_fd <= 0)
            PLERROR("Cannot create socket");
        address.sin_family = AF_INET;
        address.sin_addr.s_addr = INADDR_ANY;
        address.sin_port = htons(port_no);

        if (bind(socket_fd, (struct sockaddr *)&address, addr_len))
            PLERROR("Cannot bind socket"); // ... and in the darknest bind them
        listen(socket_fd, max_connections);
        int nodelay = 1;
        setsockopt(socket_fd, IPPROTO_TCP, TCP_NODELAY, (char *)nodelay, sizeof(int));
    }
struct sockaddr_in* PLearn::IPServer::get_address ( ) [inline, read]

Definition at line 79 of file IPopen.h.

Referenced by PLearn::IPopen::establish_communication().

{ return &address; };

Here is the caller graph for this function:

int PLearn::IPServer::get_socket_fd ( ) [inline]

Definition at line 78 of file IPopen.h.

Referenced by PLearn::IPopen::establish_communication().

{ return socket_fd; };

Here is the caller graph for this function:

string PLearn::IPServer::machine_name ( ) [inline]

Definition at line 80 of file IPopen.h.

References PLearn::hostname().

{ return hostname(); };

Here is the call graph for this function:

int PLearn::IPServer::port_no ( ) [inline]

Definition at line 81 of file IPopen.h.

{ return port; };
static void PLearn::IPServer::set_ip_port ( int  port_no,
int  max_connections_ = 100 
) [inline, static]

Definition at line 109 of file IPopen.h.

References ip_port, and max_connections.


Member Data Documentation

struct sockaddr_in PLearn::IPServer::address [protected]

Definition at line 86 of file IPopen.h.

int PLearn::IPServer::ip_port = 15000 [static]

Definition at line 107 of file IPopen.h.

Referenced by set_ip_port().

Definition at line 108 of file IPopen.h.

Referenced by set_ip_port().

Definition at line 85 of file IPopen.h.

Definition at line 81 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