Accessing member functions of sockaddr_in
Hello,
I am working on a small project in Linux that allows communication to and from a server. So far I have my concept in mind, and source code close to flawless. Though, I have a small problem. To reduce the size of code used in main, I created a structure to allow the handles of clients, sockets, and other information store in different areas. Though, to make my job easier, I want to pass the address of a sockaddr_in and access its members inside a function.
Though, when I do, it gives an error as the following: "request for member 'sin_family' in something not a structure or union"
Here is a code sample:
Code:
void setInfo(struct sockaddr_in *sock) {
memset(sock, 0, sizeof(*sock));
*(sock.sin_family) = AF_INET;
*(sock.sin_port) = htons(port);
*(sock.sin_addr.s_addr) = INADDR_ANY;
}
int main() {
struct sockaddr_in server;
setInfo(&server);
return 0;
}
Compiled with GCC 3.4.3 | Slackware 10.0
At this moment, I'm clueless of why it won't accept the indirection (*) operator. Any help would be appreciated.
- Stack Overflow