[ee122] question about slide 23 of Sockets ppt

Jorge Ortiz jortiz at cs.berkeley.edu
Sat Sep 15 15:59:50 PDT 2007

host->h_addr_list[0] is a pointer of type char*.  So we have to cast
it to a pointer of type in_addr_t* type.  After the cast, it's still
just a pointer to an in_addr_t.  So then we have to dereference it to
get the value.


On 9/15/07, Davide Cerri <davide.cerri at gmail.com> wrote:
> hello,
> i am trying to follow the code provided, but i get confused by this line
> in_addr_t server_addr = *(in_addr_t *) host->h_addr_list[0];
> why are we casting and de referencing instead of casting (in_addr_t)
> what kind of magic does this trick?
> thanks
> --
> ~/Davide Cerri
> _______________________________________________
> ee122 mailing list
> ee122 at mailman.ICSI.Berkeley.EDU
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/ee122

More information about the ee122 mailing list