Any one could describe how (struct sockaddr *)&server
works here? Is it possible to cast bigger struct to smaller struct?
See these structs:
This is C's form of "inheritance" (notice the quotes). This works because C does not care about the underlying data in an address, just what you represent it as.
The function determines what structure it actually is by using the sa_family field, and casting it into the proper sockaddr_in
inside the function.