Share socket fd between two processes

Hello every one i am implementing client server program.To handle multiple fds of client in server i used poll function.But this poll not able to access socket fd from other process.How can i share socket fd between two process.

Please Help me,Thanks in advance.

When a program fork()s, its file descriptors get inherited by the parent - not sure if this is the only way, but it's certainly a way.

Some web servers have passed accepted socket fd through sockets or pipes to pre-spawned helper processes on the same host. There is a procedure for turning the fd into a portable reference upstream and then back to a new fd on the downstream end. I will Google.

---------- Post updated at 01:47 PM ---------- Previous update was at 01:46 PM ----------

pass fd through pipe OR socket - Google Search

portlisten: passing socket file descriptors through sockets

---------- Post updated at 01:52 PM ---------- Previous update was at 01:47 PM ----------

These days, the trend is to use threads in one process.

There are ways to up the fd limit of a process, including the obvious one of forking off a child to close the listen/accept fd and finish all open I/O and let the parent close all the service fd and go back to accepting. This way, you get good response on short requests but long ones, if there are too many, are spun off once they get to the long part.

FWIW - consider reading 'Advanced Programming in the UNIX Environment' by Stevens & Rago.

It covers how to pass socket descriptors among processes. DGP mentioned one basic way.
There are others that do not involve threads, only sockets.

This kind of thing is way beyond what we can post here in the forums.