Return-Path: william@bourbon.usc.edu Delivery-Date: Mon Sep 8 20:53:02 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m893r2ck030863 for ; Mon, 8 Sep 2008 20:53:02 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m893q9Ti013843 for ; Mon, 8 Sep 2008 20:52:09 -0700 Message-Id: <200809090352.m893q9Ti013843@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent Date: Mon, 08 Sep 2008 20:52:09 -0700 From: Bill Cheng Someone wrote: > Well I thought that when I call inet_aton() with www.cs.usc.xxxx 0 should be > returned (as opposed to 24.28.193.9 and a non zero return val) so that I > could identify it and send the failure response message. Sounds like I might > be missing something simple. > > The inet_aton() routine interprets the specified character string as an > Internet address, placing the address into the structure provided. It > returns 1 if the string was successfully interpreted, or 0 if the string > is invalid. The inet_addr() and inet_network() functions return numbers > suitable for use as Internet addresses and Internet network numbers, > respectively. Ah! I see what you are asking now. inet_aton() expects the input to be dotted numbers! It's a simple format conversion routine. So, you should not use it to resolve hostnames to IP addresses. You should check the input. If the input is in the dotted number format, then you should call inet_aton(). If it looks like a hostname, you should call gethostbyname(). -- Bill Cheng // bill.cheng@usc.edu -----Original Message----- From: Bill Cheng [mailto:william@bourbon.usc.edu] Sent: Monday, September 08, 2008 8:23 PM To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent Someone wrote: > When I pass in strings like cs.usc.xxxx to inet_aton() I get 24.28.193.9 and > a non-zero return value, but when I pass in nonsense like werwerw the > function returns 0 as the man pages say it will. Valid address work just > fine. Any idea what might be causing that? Hmm... I'm not sure what you are asking. Sounds like it's doing what you want. Could you give a more concrete example of when it does something you don't want? -- Bill Cheng // bill.cheng@usc.edu -----Original Message----- From: Bill Cheng [mailto:william@bourbon.usc.edu] Sent: Monday, September 08, 2008 6:57 PM To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent Someone wrote: > Is it acceptable if I print the IP of nunki at the server instead of the > localhost (127.0.0.1) The adr command is to get the IP address given a hostname. So, you should return the IP address if there is one. -- Bill Cheng // bill.cheng@usc.edu