network.hpp 742 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#pragma once

#include <string>
struct BatsimContext;

enum NetworkStamp : char
{
    STATIC_JOB_ALLOCATION = 'J',
    JOB_REJECTION = 'R',
    NOP = 'N',
    STATIC_JOB_SUBMISSION = 'S',
12
    STATIC_JOB_COMPLETION = 'C',
13 14 15 16
    PSTATE_SET = 'P',
    NOP_ME_LATER = 'n',

    PSTATE_HAS_BEEN_SET = 'p'
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
};

class UnixDomainSocket
{
public:
    UnixDomainSocket();
    UnixDomainSocket(const std::string & filename);
    ~UnixDomainSocket();

    void create_socket(const std::string & filename);
    void accept_pending_connection();
    void close();

    std::string receive();
    void send(const std::string & message);

private:
    int _server_socket;
    int _client_socket;
};

int request_reply_scheduler_process(int argc, char *argv[]);