[cs631apue] hw4 questions.
afonsec1
afonsec1 at stevens.edu
Mon Nov 14 14:41:22 EST 2011
On Mon, 14 Nov 2011 14:22:16 -0500, Jan Schaumann wrote:
> afonsec1 <afonsec1 at stevens.edu> wrote:
>
>> If we are in debug mode and therefore not daemonize, should we still
>> support signal handling? should we do a restart for signal handling?
>
> Try to think about whether or not that makes sense. What do you want
> to
> debug when you are in debug mode? Does that possibly include the
> behaviour upon receiving a signal?
>
>> From my understanding, when we go daemon, we close all file
>> descriptor
>> for the giving process, so if we passed a log file name, we have to
>> open
>> a descriptor to that file?
>
> In order to write anything to the log file you require a file handle,
> correct.
>
>> Since we close the stderr fd on daemon mode too, should we log the
>> fatal
>> messages (messages about reasons for terminating the program) on the
>> syslog? or just terminate without logging the event?
>
> syslog(3) is the best solution, yes.
>
>> I didn't specify the ai_family, so the way that I get address info
>> is
>> agnostic.
>
> I'm not sure I understand you correctly, but what you are describing
> does not sound like it'd be portable code. Can you provide an
> example
> of what you're doing?
>
>> Hence it really doesn't matter whether the address passed on the
>> (-i)
>> option is ipv6, or ipv4, it will recognize it dynamically. Are you
>> okay with this? or do you want us to hard-code the address family?
>
> Handling of IPv6 should be done explicitly. (This also means that
> the
> end user can implicitly disable it, which it sounds like it wouldn't
> be
> possible in your approach.)
>
> -Jan
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/cgi-bin/mailman/listinfo/cs631apue
> I'm not sure I understand you correctly, but what you are describing
> does not sound like it'd be portable code. Can you provide an
> example
> of what you're doing?
According to
http://pubs.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html
"A value of AF_UNSPEC for ai_family means that the caller shall accept
any address family."
So if I pass ::1 or 127.0.0.1, getaddrinfo returns successfully.
struct addrinfo info;
info.ai_family= AF_UNSPEC;
info.ai_socktype = SOCK_STREAM;
info.ai_flags = AI_PASSIVE;
const char *address_str; // ipv6 or ipv4 address. If NULL, then get an
address
if ((status = getaddrinfo(address_str, itoa(portnum, 10), &info,
&res_list)) != 0)
That is why I didn't see the point of toggling ipv6 address format, but
I guess we need to do it explicitly.
Thanks,
Armando.
More information about the cs631apue
mailing list