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 8474459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:37:56+00:00 2026-06-10T17:37:56+00:00

Here is what I have so far socklen_t cli_size; struct sockaddr cli; int in_sock;

  • 0

Here is what I have so far

socklen_t cli_size;
struct sockaddr cli;
int in_sock;

/* event from TCP server socket, new connection */
cli_size = sizeof(cli);
try {
    if ((in_sock  = ::accept(handle,&cli, &cli_size)) < 0) {
        throw in_sock;
        return NULL;
        }
    }
catch(int ex) {
    cout << "Exception Nr. " << ex << endl;
    }

from man page:

On error, -1 is returned, and errno is set appropriately.

Question: I still can’t understand where is errno? I need to understand exception

  • 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-06-10T17:37:57+00:00Added an answer on June 10, 2026 at 5:37 pm

    errno is a global integer variable that contains error codes after system calls like accept fails. You might have to include the header file <errno.h> for the variable to be defined.

    In your case, you shouldn’t throw the value returned by accept but the value of errno:

    try
    {
        if ((in_sock = accept(...)) == -1)
            throw errno;
        // ...
    }
    catch (int error)
    {
        std::cout << "Error code " << error << " (" << std::strerror(error) << ")\n";
    }
    

    The function std::strerror is declared in the header file <cstring> and returns a string describing the error.

    An important note: The value of errno is only valid if a function returns that it failed. If, in your example, accept succeeds then the value of errno is undefined.

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

Sidebar

Related Questions

Here's what I have so far: create table rubro ( id_rubro int primary key,
Here's what I have so far: var bestReason = from p in successfulReasons group
Here is what I have so far : def mergesort[T <: Ordered[T]](elements : List[T])
http://pastebin.com/mYk8M038 here is what I have so far... I think it may be something
I'm using the Firefox Add-on Builder and here is what I have so far:
I'm fairly new to JS, here's what I have so far. I can get
I'm a total newb to LINQ. Here is the code I have so far:
Here is what I have tried thus far: > cd /Applications/MAMP/bin/php5/bin/ > ./pear channel-discover
I really wonder why this question hasn't popped up here so far. I have
Here is what I have so far: type Maybe<'a> = option<'a> let succeed x

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.