Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why does connect() succeed even before my server did an accept()?



Why does connect() succeed even before my server did an accept()?..

Answer / chaitanya

Once you have done a listen() call on your socket, the kernel is primed to accept connections on it. The usual UNIX implementation of this works by immediately completing the SYN handshake for any incoming valid SYN segments (connection attempts), creating the socket for the new connection, and keeping this new socket on an internal queue ready for the accept() call. So the socket is fully open before the accept is done.

The other factor in this is the 'backlog' parameter for listen(); that defines how many of these completed connections can be queued at one time. If the specified number is exceeded, then new incoming connects are simply ignored (which causes them to be retried).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Unix Socket Programming Interview Questions

How can I put a timeout on connect()?

1 Answers  


After the chroot(), calls to socket() are failing. Why?

1 Answers  


How can I bind() to a port number < 1024?

1 Answers  


Are unix sockets faster than tcp?

0 Answers  


How come select says there is data, but read returns zero?

1 Answers  


How can I read only one character at a time?

1 Answers  


What is difference between socket and websocket?

0 Answers  


Can a socket have multiple ports?

0 Answers  


Where can a get a library for programming sockets?

1 Answers  


How do unix sockets work?

0 Answers  


When will my application receive SIGPIPE?

1 Answers  


What is sae socket?

0 Answers  


Categories