myrecv.cpp 387 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <sys/socket.h>

#include "myrecv.h"

int myrecv(int sock,void *buffer,int len, int flags) {
        int n=len;
        char *mybuff=(char*)buffer;
        int r;
        do {
                r=recv (sock, mybuff, n, flags);
                if (r<0)
                        return r;
                mybuff+=r;
                n-=r;
        } while (n>0);
        return len;
}