I am trying to write a wrapper class for simplicity around sockets so they are easily portable. I know accept() waits untill you connect() from the client, but is there a way to check if there is something to accept() before calling accept()?

An analogy I don't wait with my front door open untill my friend shows up I wait for the doorbell before I open the door and go about my business then go answer the door.

I mean there must be some way to check or maybe timeout accept() right? I would prefer not to use threads as I am not familiar with them fork() seems to not share data across threads - I'm not sure if globals are still accessible by all or not in that case. If there is a way to check before accept()ing that would be a big help.