UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2002-07-27 12:08 AM

HectorLasso
Administrator
From: Colombia
Registered: 2002-06-12
Posts: 353

Re: 6.3 - Complete read without select()

while (1) 
    { 
        bzero(buffer, sizeof(buffer)); 

        /* PEEK but not read from receive buffer first */ 
        readcount = recv(socketfd, buffer, 
                         sizeof(buffer), MSG_PEEK); 
        if (readcount <= 0) 
            break; 

        recv(socketfd, buffer, strlen(buffer)+1, 0); 
        fprintf(stdout, "%s\n", buffer); 
    }

Offline

Board footer

Powered by FluxBB