[Csci551-talk] IP address

Michael Stephens mikestephens at gmail.com
Fri Mar 25 19:16:48 PST 2005


Are you saying to use
  serveraddr.sin_addr.s_addr = htonl(INADDR_ANY)

before the call to "connect" in the tracker, when the tracker is
trying to connect to the manager?

This is does not give you the IP address of the manager, it gives you
the IP address of the tracker, right?  Isn't this antithetical to what
Xi said in a previous post:

> Although for this project all nodes run on a single machine, your basic
> design should allow them to work on different machines.

The approach you are now suggesting would not allow them to work on
different machines, correct?  Perhaps I do not yet understand...


On Fri, 25 Mar 2005 18:49:46 -0800, rashmi chandrasekhar
<rmchandr at usc.edu> wrote:
> 
> It is sufficient for this project if you just set
> serveraddr.sin_addr.s_addr=htonl(INADDR_ANY);
> and likewise for the tracker and the clients. Since all processes are running on the same machine, the above will return the same IP address in all cases.
> 
> -Rashmi.
> 
> ----- Original Message -----
> From: Michael Stephens <mikestephens at gmail.com>
> Date: Friday, March 25, 2005 6:42 pm
> Subject: Re: [Csci551-talk] IP address
> 
> > I figured out the problem.
> >
> > The kernel does not assign an IP address to the socket until after
> > "accept" returns (after the tracker has called "connect").
> > Unfortunately at this point it is too late to tell the tracker which
> > IP address to connect to!
> >
> > The way I tried to solve this was to do the following:
> > - Call gethostname to get the host name
> > - Call gethostbyname.  This returns a list of IP addresses that the
> > host can have.
> >
> > Now at this point I just picked the first IP address in the list and
> > it seems to work so far.  I suppose to be more robust the entire list
> > of IP addresses should be passed to the Tracker and it should try all
> > of them before giving up, but I am not sure if that is necessary.
> >
> > Does this sound reasonable or am I way off track?
> >
> >
> > On Fri, 25 Mar 2005 17:49:24 -0800, Affan, Syed <asyed at usc.edu> wrote:
> > > Are you using IN_ADDR_ANY before calling getsockname()?
> > >
> > > Best Regards,
> > > Affan, Syed.
> > >
> > >
> > > -----Original Message-----
> > > From: csci551-talk-bounces at mailman.isi.edu
> > > [csci551-talk-bounces at mailman.isi.edu] On Behalf Of Michael
> > > Stephens
> > > Sent: Friday, March 25, 2005 3:52 PM
> > > To: csci551-talk at mailman.isi.edu; xiw at usc.edu
> > > Subject: [Csci551-talk] IP address
> > >
> > > Xi Wang wrote:
> > > > To me the address is more like 173.132.2.0. You might have
> > used wrong
> > > > byte order.
> > >
> > > First I call "getsockname" to get the IP address.  The resulting
> > > socketaddr_in should have the IP address in network byte order,
> > right?> Then I call inet_ntop to convert this to a string.
> > inet_ntop assumes
> > > that the address is already in network byte order according to
> > the man
> > > page.  Then I pass the string to the tracker and convert it back to
> > > network format using inet_pton.
> > >
> > >
> >
> 
>


More information about the Csci551-talk mailing list