All pastes #942884 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-14 20:22 UTC
rendered paste body
//--------

void sendLine(int new_fd, char * Buffer) 
{
    send(new_fd, Buffer, BUFFER_SIZE, 0);
    send(new_fd, "$", 1, 0);
}

//--------

void receiveLine(int new_fd, char * Buffer, int size) 
{
    int len = 0;
    while (1) 
        {
            int n = recv(new_fd, &Buffer[len], 1, 0);
            if (n <= 0 || Buffer[len] == '$')
                break;
            if (len < size - 1)
                len++;
        }
    Buffer[len] = '$';
}