Return-Path: william@bourbon.usc.edu Delivery-Date: Tue Sep 9 20:07:42 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 m8A37gPi014696 for ; Tue, 9 Sep 2008 20:07:42 -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 m8A374cF005625 for ; Tue, 9 Sep 2008 20:07:04 -0700 Message-Id: <200809100307.m8A374cF005625@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent Date: Tue, 09 Sep 2008 20:07:04 -0700 From: Bill Cheng Someone wrote: > I had performed that same test with no luck. I am using cygwin, could that > be the problem? > > struct hostent *p_hostent = NULL; > p_hostent = gethostbyname("www.cs.usc.xxxx"); > assert(p_hostent == NULL); Interesting! On my cygwin at home, "www.cs.usc.xxxx" also resolves to "24.28.193.9"! I then ran the following on cygwin: nslookup www.cs.usc.xxxx I got: *** Can't find server name for address 192.168.1.1: Non-existent domain *** Default servers are not available Non-authoritative answer: Server: UnKnown Address: 192.168.1.1 Name: www.cs.usc.xxxx.rr.com Address: 24.28.193.9 Since it matches what nslookup is returning, the good news is that the code seems to be doing the right thing! My service provider is rr.com. May be their resolver is being aggressive. This is probably not a cygwin thing but a rr.com thing! -- Bill Cheng // bill.cheng@usc.edu -----Original Message----- From: Bill Cheng [mailto:william@bourbon.usc.edu] Sent: Tuesday, September 09, 2008 8:08 AM To: cs551@merlot.usc.edu Subject: Re: Regarding data being sent 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