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:15 AM

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

Re: 6.4 - How to use select routine

int sock_ready(sock) 
int sock; 
{ 
    int             res; 
    fd_set          sready; 
    struct timeval  nowait; 

    FD_ZERO(&sready); 
    FD_SET((unsigned int)sock,&sready); 
    /*bzero((char *)&nowait,sizeof(nowait));*/ 
    memset((char *)&nowait,0,sizeof(nowait)); 

    res = select(sock+1,&sready,NULL,NULL,&nowait); 
    if( FD_ISSET(sock,&sready) ) 
        res = 1; 
    else 
        res = 0; 

    return(res); 
}

Offline

Board footer

Powered by FluxBB