Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Oct 1996 11:14:33 +0900 (JST)
From:      Michael Hancock <michaelh@cet.co.jp>
To:        Per Hojmark <per@via.net>
Cc:        hackers@freebsd.org
Subject:   Re: sockets programming question
Message-ID:  <Pine.SV4.3.93.961029110507.29545A-100000@parkplace.cet.co.jp>
In-Reply-To: <199610290018.QAA21190@mustang.via.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 28 Oct 1996, Per Hojmark wrote:

> 
> I want to build a database server process that:
>    -   listens on a port
>    -   connects to incoming users
>    -   forks to create new state & connection info for database.
>    -   does some database lookups
>    -   returns info to user 
>    -   closes connection.
>  
> So, suppose I was listening on port 1234, when I get a connection
> from a remote machine, do I need to switch to a new port number?
>  
> I notice that many programs use 'well known' port numbers, but after
> forking, seem to switch to a port > 1024. It appears that they use
> the 'well-known' port number just for the initial connection.

The deamon needs to run as root to listen on low numbered ports.  While
you're root you can write the logs and then hand off the real work to the
children which run as a different uid and switch to a high numbered port. 

The loop you describe is so common that you should try to use a library. 
Try asking at http://www.isc.org for the eventlib. 

Regards,


Mike Hancock




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.93.961029110507.29545A-100000>