1. Start a listen() on a socket, stop it, then start it again
I have been working on a server style program for a little while now, and
things are starting to get a little bit interesting. For various reasons,
I would like to be able to accept up to a certain amount of concurrent
connections, at that point have additional connections refused/ignored, and
then be able to start accepting again new connections again when some of
the earlier ones go away. Here is what I have been able to determine:
- If I start listening, accept a connection, and then close the listening
socket, I can then re-bind to the same port number and start listening
again while the accepted connection stays up
- If I start listening, fork off a child, and close the listening socket
in the child and the parent, I can then re-bind to the same port and start
listening again
- If I accept a connection, fork off a child, close the listening AND
accepted sockets in both the parent and the child, I can also re-bind and
continue
- If I accept a connection, fork a child, close both sockets in the
parent, but only the listening socket in the child, if I try to re-bind to
the same port number in the parent to listen again, I get an address-in-use
error.
Unfortunately, the fourth case is the one I need to work differently. The
processes I fork off will need to keep their connections open, but at the
same time I would like the parent to stop listening until the number of
child processes drops below a certain number. Setting SO_REUSEADDR doesn't
help since the connection is in an ESTABLISHED state, not TIME_WAIT.
Has anyone tried to do something similar and figured out a way to make it
work?
I am currently working under SCO Unixware (2.1), but need my solution to be
fairly generic (i.e. portable) since I need it to work under SVR4 and HP,
and possibly others in the future.
Thanks in advance for any help.
-> Thayer York
2. ICQ ??
3. Quick: error opening filesystem
4. SOLVED: LILO boot from floppy
5. Lin/pmac>>Quick is unable to open filesystem
6. second hme doesn't come up
7. Quick Filesystem Question
8. network printing on a Dell unix box
9. Veritas FileSystem & Quick I/O on Solaris
10. newbie, quick way to create a quota on an NFS exported filesystem - HELP
11. Veritas FileSystem & Quick I/O on Solaris
12. Veritas Quick IO filesystem
13. Quick jump-start with Apache web server