On Wed, 23 Oct 2002 22:45:06 + (UTC) in lucky.freebsd.questions, Vinod wrote:
i need a socket descriptor handle to process all my
clients which fork out.but the handle i was using
new_fd(see below) turned out to be the same for all.
listen(..,..)
for(;;)
{
int new_fd=accept(sockfd,,...);
...
}
Shouldnt the new_fd be distinct everytime a new client
connects?
I don't clearly understand your question, especially if you
read Stevens books, but I'll try to answer.
new_fd variable is just overwritten each time accept() returns a new
socket descriptor for a new connection. If you need to keep connections
with all clients at the same time in a single server, so, you need to
save each new_fd descriptor in an array, for example.
If you fork() a new process for handling a new connection, then you need
to close() new_fd descriptor in the server and use new_fd descriptor in
the forked process.
In any way, it is better to ask such questions in comp.unix.programmer
news group.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message