While trying the following the address in the second sockaddr changes:
/*Stuff*/
sockaddr add1, add2;
recvfrom(/*socket*/, /*buffer*/, /*count*/, /*flag*/, &add1, /*fromlen*/);
add2 = add1; //The sa_data - part changes O_o...
/*Stuff*/
Anyone knows why?…
EDIT: 1.I changed the sockaddr to sockaddr_storage which definetly has enough space for sockaddr_in!!
2. I memset the structure to zero on initialization
3. I wrote a copy ruitine for my copy/assignment wishes:
memcpy(&AddrTarget, &AddrSource, sizeof(sockaddr_storage));
But this does not help, too!… Im desperate:(…
How is
fromlenbeing set when you callrecvfrom()? Iffromlen > sizeof(add1), you are possibly writing overadd2by accident.Beej’s Guide suggests that you use local variables of type
struct sockaddr_storage, which is guaranteed to be big enough to hold any of thestruct sockaddr_foos in use.