Return-Path: william@bourbon.usc.edu Delivery-Date: Thu Oct 30 11:42:04 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.4 required=5.0 tests=AWL,BAYES_00,WEIRD_PORT autolearn=no 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 m9UIg4dF006010 for ; Thu, 30 Oct 2008 11:42:04 -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 m9UIrgKO012993 for ; Thu, 30 Oct 2008 11:53:42 -0700 Message-Id: <200810301853.m9UIrgKO012993@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: gethostbyname giving error Date: Thu, 30 Oct 2008 11:53:42 -0700 From: Bill Cheng Someone wrote: > In the c8-n07.ini file, there is only 1 beacon node which is > localhost:18007, so when gethostname is called and say it returns > nunki,usc.edu, what should be done? "c8-n07.ini" looks like: [init] Port=18007 Location=30687 HomeDir=/home/scf-22/csci551b/tmp/final1/n07 AutoShutdown=90 MsgLifetime=15 KeepAliveTimeout=10 [beacons] nunki.usc.edu:18007= Let's say hostname_str contains "nunki.usc.edu" and port_str contains "18007", which is what you have read from the [init] section. Then you can do: char buf[256]; snprintf(buf, sizeof(buf), "%s:%s", hostname_str, port_str); Then you can see if what's in buf can be found as a key in the [beacons] section of the same startup configuration file. If it can be found, this node is a beacon node. Otherwise, it's regular node. -- Bill Cheng // bill.cheng@usc.edu On Thu, Oct 30, 2008 at 11:44 AM, Bill Cheng wrote: > Someone wrote: > > > Does a beacon node get its hostname from the startup configuration fle > > or by gethostname()? > > A node first calls gethostname() and then compare it with > what's in the startup configuration to determine if it is a > beacon node. > -- > Bill Cheng // bill.cheng@usc.edu > > > > > On Thu, Oct 30, 2008 at 8:53 AM, Bill Cheng wrote: > > Someone wrote: > > > > > gethostbyname is returning null, saying Too many open files. Please help. > > > > If you write a small program with just a call to gethostbyname() > > in it, I assume that works. Therefore, the problem is not > > gethostbyname(). May be you have too many files/sockets opened. > > Do you know how many files/sockets you have opened? > > > > In general, you need to know how much resources you are using. > > -- > > Bill Cheng // bill.cheng@usc.edu