FD_CLR is crashing

Posted on 2006-05-28
Last Modified: 2012-08-14
In the following piece of code FD_CLR is crashing ?

Compiler : VC++ 6
OS          : Win XP

The same piece of code is working in Linux.

Could u pls help me in resolving this.

                  fd_set rfds;
                FD_CLR(0,&rfds); // Crashed, Reason : Unhandled Exception, Illegal Istruction.
            FD_SET(0, &rfds);      
            retVal = select(0, NULL, NULL, NULL, &tv);
            if (-1 == retVal)
                             // Action
Thanks for ur valuable time in helping me in this.

Question by:k_kalyan
    LVL 49

    Expert Comment

    At first guess, it would because you have not pre-set the members of fd_set.  I believe normal usage, is for instance:

    fd_set rfds;
    rfds.fd_count= 6;
    FD_CLR( 0, &rfds ); // should avoid the crash
    LVL 49

    Accepted Solution

    Actually, it appears to be more common to use
       FD_ZERO( &rfds );
    ... as the first stage of intiializing the fd_set structure.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now