William Murphy wrote:
> Hi all,
>> Just having one or two problems writing a little network daemon:
>> 1. Most programs in the inetutils distribution seem to lose their
> controlling terminals as follows:
>> int tty = open( "/dev/tty", O_RDWR );
> ioctl( tty, TIOCNOTTY );
> close( tty );
>> All of the function calls proceed successfully, but the program stays in
> the foreground. The alternative of fork()ing seems kinda like cheating.
> Any ideas?
>
fork(), it's less messy.
>> 2. I want the program to listen on a given port on all network
> interfaces. Programs running under inetd do this, but my program is
> standalone.
> Other standalone daemons seem to do this. Obviously when one binds to a
> local address, it only listens on the interface to which that address
> belongs, eg if i bind with the address 127.0.0.1, then my program won't
> listen on my ethernet card's address.
>
Don't bind to a specific network address, use INADDR_ANY.
>> Thanks in advance,
> William Murphy
> <alias at student.nuigalway.ie>
>> --
> Irish Linux Users' Group: ilug at linux.ie>http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie
--
===============================================================================
John Allen, Email: john.allen at orbiscard.com
Orbis Payment Technology Ltd, Phone: +353-1-2945111
3 Sandyford Park, Mobile: +353-86-2315986
Sandyford Industrial Estate, Fax: +353-1-2945119
Dublin 18.
===============================================================================
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!