Return-Path: william@bourbon.usc.edu Delivery-Date: Tue Sep 9 08:08:59 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 m89F8xPF006744 for ; Tue, 9 Sep 2008 08:08:59 -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 m89F8EnX026016 for ; Tue, 9 Sep 2008 08:08:14 -0700 Message-Id: <200809091508.m89F8EnX026016@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent Date: Tue, 09 Sep 2008 08:08:14 -0700 From: Bill Cheng Someone wrote: > I thought I was doing that. I was using your example from Lecture 2 and it > seems that commenting out this line "memset(&my_addr, 0, sizeof(struct > sockaddr_in));" made things behave properly. I am still confused though, > because I was checking h_errno returned by gethostbyname() and it was always > 0. Is there significance to this addr: 24.28.193.9 as it was the default > when hostnames were not resolved correctly I just wrote a tiny program to call gethostbyname("www.cs.usc.xxxx") and it returns NULL. Please do the same! May be this function is not working right for you because you have bugs in other parts of your program! -- Bill Cheng // bill.cheng@usc.edu -----Original Message----- From: Bill Cheng [mailto:william@bourbon.usc.edu] Sent: Monday, September 08, 2008 8:52 PM To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent 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