Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:04:19+00:00 2026-05-23T16:04:19+00:00

hi right now im trying to know if a client or the server disconnected

  • 0

hi right now im trying to know if a client or the server disconnected and then send an error but i cant seem to make it work and ive got no idea how to do this so i really need help plz

here’s my code

    #ifdef _WIN32 || _WIN64
            if(select(0,&fd_read,NULL,&fd_close,&time)==-1){
                printf("Error in Select()");
                return 0;
            }
    #else
            if(select(sockMax + 1,&fd_read,NULL,&fd_close,&time)==-1){
                printf("Error in Select()");
                return 0;
            }
    #endif

 if(FD_ISSET(socklisten,&fd_read)){

        }
        else
        {
            dopack(&pkt);
            send(socklisten, (char*)&pkt, sizeof(pack), 0);
        }


//this is where the error shows -----------
        if(FD_SET(socklisten,&fd_close))
        {
            backtoMenu = true;
        }

        FD_ZERO(&fd_leer);

        FD_SET(sockEscucha,&fd_leer);

The error says expected primary-expression before ‘do’
so yeah i’ve got no idea what that means
and just in case this is how im declaring fd_read and fd_close

fd_set fd_read;       
fd_set fd_close;   

plz any help would be really appreciated tyvm

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:04:20+00:00Added an answer on May 23, 2026 at 4:04 pm

    What Richard said, in addition, the third fd_set passed to select() is not about closed FDs, but rather about some exceptional condition that requires special attention (which exactly, is defined by the underlying driver, for example, TCP sockets use it for “urgent” data.

    You detect a remote close by the return code from recv(), i.e. inside the handling for readable descriptors. If recv() on a stream socket returns 0, the remote side has closed the connection (with TCP, you can still send data as only one direction is closed); if recv() returns -1, then errno has further information, for example ECONNRESET means that a TCP RST packet was received.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm trying desperately to get @font-face to work in my website. This
I'm trying to design some bookmarklets right now, that connect back to a server
Right now I'm trying to make it so I've got 1 character and 3
I know some Java and am right now trying C++ instead and apparently in
Right now I'm trying to figure out a way to do things smarter, and
Right now I am trying to call my model, and spit out its results
Right now I'm trying to create my own tiny MVC (just for practice and
Right now I'm trying this: int a = round(n); where n is a double
I'm developing an object-oriented PHP website right now and am trying to determine the
Right now I have been trying to use Launchpad's API to write a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.