Method to read _popen() output in chunks/send via TCP?

I am attempting to read the output of _popen in chunks and send it via TCP to a server receiving the output. I can successfully read the output and print to stdout (client side), however when sending via TCP the receiver/server doesn't receive the correct data (excess data/bytes).

Sender code:

void send_output(SOCKET client_sock) {
    const int BUFLEN = 8192;
    FILE *fpipe;
    char buf[BUFLEN + 1] = { 0 };

    fpipe = (FILE*)_popen("type 229401.txt", "r");

    // Store command output.
    int rb, iResult = 0;
    do {
        rb = fread(buf, 1, BUFLEN, fpipe);
        printf("%s\n", buf);
        send(client_sock, buf, rb, 0);
        memset(buf, '\0', rb);
    } while (rb == BUFLEN);
    // Close the process.

Receiver code:

char buf[BUFLEN + 1];
void receive_output(SOCKET client_socket) {
    int iResult = 0;
    do {
        iResult = recv(client_socket, buf, BUFLEN, 0);
        buf[BUFLEN + 1] = '\0';
        printf("%s", buf);
    } while (iResult == BUFLEN && iResult != SOCKET_ERROR);

I am attempting to send the output of the type command (cat for windows) of a text file containing 229401 bytes to no avail.

I am trying to avoid redundant memory allocation and string copying/concatenation.

Is there something I'm doing wrong? How do I efficiently send the output of _popen via TCP in chunks?