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

  • Home
  • SEARCH
  • 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 9194143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:20:12+00:00 2026-06-17T21:20:12+00:00

Is there possible that accept() (on redhat Enterprise 4/linux kernel 2.6) return a same

  • 0

Is there possible that accept() (on redhat Enterprise 4/linux kernel 2.6) return a same socket value for different tcp connections from the same process of a same application and same machine?

I am so surprised that when I got such a result that many connections have the same socket value on server side when I checked the log file!! How is it possible?!!

By the way, I am using TCP blocking socket to listen.

    main(){
        int fd, clientfd, len, clientlen; 
        sockaddr_in address, clientaddress;

        fd = socket(PF_INET, SOCK_STREAM, 0);
        ....
        memset(&address, 0, sizeof address);

        address.sin_address = AF_INET;
        address.sin_port = htons(port); 
        ....
        bind(fd, &address, sizeof address);
        listen(fd, 100);
        do {
             clientfd = accept(fd, &clientaddress, &clientlen); 

             if (clientfd < 0) {
             ....
             } 

             printf("clientfd = %d", clientfd);  

             switch(fork()){
             case 0:

                    //do something else
                    exit(0);
             default:
                     ...
             }


          } while(1);
    }

my question is that why printf("clientfd = %d"); prints a same number for different connections!!!

  • 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-17T21:20:13+00:00Added an answer on June 17, 2026 at 9:20 pm

    If server runs in multiple processes (like Apache with mpm worker model), then every process has its own file descriptor numbering starting from 0.

    In other words, it is quite possible that different processes will get exact same socket file descriptor number. However, fd number it does not really mean anything. They still refer to different underlying objects, and different local TCP ports.

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

Sidebar

Related Questions

Is it possible that there are more than one certificate chain built during the
is there a possible bit of code (php, java, css, html) that will force
I was wondering ( if possible ) if there was a program/tool/utility that when
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Possible Duplicates: Is there a problem that has only a recursive solution? Can every
Possible Duplicate: Is there a standard date/time format that can be passed on a
Possible Duplicate: Concatenate Two NSDate String values Just confused that is there any default
Possible Duplicate: Is there a CSS parent selector? CSS selector for “foo that contains
cgi.escape seems like one possible choice. Does it work well? Is there something that
In Java is there anyway to have one constructor that will accept an array

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.