msg.c
author viric@llimona
Sun, 25 Mar 2007 04:55:18 +0200
changeset 23 96fcebb68510
parent 21 a797f96a022f
child 32 3531439f2770
permissions -rw-r--r--
More TODO for the next versions.

#include "msg.h"

void send_bytes(const int fd, const char *data, const int bytes)
{
    int res;
    /* Send the message */
    res = send(fd, data, bytes, 0);
    if(res == -1)
    {
        perror("c: send");
        exit(-1);
    }
}

int recv_bytes(const int fd, char *data, const int bytes)
{
    int res;
    /* Send the message */
    res = recv(fd, data, bytes, 0);

    return res;
}

void send_msg(const int fd, const struct msg *m)
{
    int res;
    /* Send the message */
    res = send(fd, m, sizeof(*m), 0);
    if(res == -1)
    {
        perror("c: send");
        exit(-1);
    }
}

int recv_msg(const int fd, struct msg *m)
{
    int res;
    /* Send the message */
    res = recv(fd, m, sizeof(*m), 0);

    return res;
}