[ee122] sockaddr_in and pointers.
huntingtonsurfca at gmail.com
Sat Sep 22 22:11:46 PDT 2007
The sockaddr_in struct doesn't like to be modified via a pointer.
I'm trying to modularize my code but this is preventing me from doing so.
prototype: char *clientParse(char*buff, struct sockaddr_in *serv, ...)
and calling it: sBuff = clientParse(inBuff, &serv_addr, &my_addr);
I dereference the pointer in the function like this:
serv->sin_family = AF_INET;
But when I try to bind the connection, using the serv_addr (in main), it
So I tried making local variables (in the function) and then:
memcpy(serv, &servAddr, sizeof(struct sockaddr_in)); (in function)
but this is still failing. Anyone else have an idea? I know this is the
reason why it is failing because I've had this problem before with it and I
found a workaround using memcpy() but that was in the same scope. I guess
that's why it didn't work across function calls.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ee122