Hi there, I'm currently trying to learn sockets, but as a beginner, I still have confusion over pointers. I've been following this online guide:
http://www.beej.us/guide/bgnet/outpu...age/bgnet.html
Anyways I'm having confusion with some of the functions etc. An example is this, which is found in the guide:
Code:
connect(sockfd, (struct sockaddr *)&dest_addr, sizeof dest_addr);
The part that confuses me is the
Code:
(struct sockaddr *)&dest_addr
. According to what I've learnt so far, ( ) is for typecasting, so what exactly is that saying? I mean, to be honest, I have no idea.. &dest_addr means the address of that variable, I get that much. * is to dereference a pointer, to get the value of the thing it's pointing too, I get that too. But to dereference a pointer doesn't it have to be at the START of the pointer, not the end? i.e *Pointer not Pointer *, which is what is used in the above example. So as you can probably tell I'm pretty confused, and if anyone could shed some light on this that'd be great, thanks a lot!
Another thing, if anyone knows of a more beginner friendly socket guide, that'd be great. Something that doesn't rely on an experienced knowledge of C, as I'm still learning, topics such as pointers confuse me, but I feel as if I have the basics down. Ok thanks a lot guys!