// create socket s
for (rp = result; rp != NULL; rp = rp->ai_next)
{
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
}
You are leaking filedescriptors (sockets) here. With every iteration of the loop s
is reassigned. And the previous value of s is lost. (I don't know how long your linked list is)
// loop for sending m x struct ECA_message_t
int m=0;
for (; m<NbMesPerFile; ++m)
{
ECA_message_t* ECA_paquet;
ECA_paquet=(ECA_message_t*)malloc(sizeof(ECA_message_t)*2400);
// 2400 to workaround some not understood memory issue and make sendto() to
// work
// function initializing ECA_paquet
Client_update_ECA_data(ECA_paquet,m);
if (sendto(s, ECA_paquet, sizeof(ECA_paquet)*2400, 0 ,(struct
sockaddr*)&si_other,slen)==-1)
{
perror("sendto()");
}
}
You are leaking memory here. With every iteration of the loop ECA_paquet
is reassigned. And the previous value of ECA_paquet is lost. Forever. (I don't know how large NbMesPerFile
is)
(this is probably not the cause of your segfault, but it at least indicates substandard quality) You should also not cast the return value of malloc(), (+ #include <stdlib.h>
, , plus check malloc()s return value. And turn up the warning level of your compiler.