Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define SERVER_IN 1219
- #define SERVER_OUT 1213
- int server_in_id;
- int server_out_id;
- int msg_flag = 0;
- struct cmd_t
- {
- char cmd;
- long pid;
- int arg[MAX_ARGS];
- };
- struct msg_t
- {
- long mtype;
- struct cmd_t message;
- };
- int initialise_communication()
- {
- if ((server_in_id = msgget(SERVER_IN, msg_flag)) == -1)
- syserr("msgget");
- if ((server_out_id = msgget(SERVER_OUT, msg_flag)) == -1)
- syserr("msgget");
- printf("communication_initialised\n\tserv_in : %d\n\tserv_out : %d\n", server_in_id, server_out_id);
- return 0;
- }
- int send_to_client(long mtype, int response[MAX_ARGS])
- {
- int i;
- struct cmd_t task;
- struct msg_t m_buf;
- task.pid = mtype;
- for (i = 0; i < MAX_ARGS; i++)
- {
- task.arg[i] = response[i];
- }
- m_buf.mtype = mtype;
- m_buf.message = task;
- if (msgsnd(server_out_id, &m_buf, sizeof(struct cmd_t), 0) == -1)
- fatal("error in msgsnd in send_to_client");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement