Bonjour a tous,
Voila dans le code d'une grosse fonction, j'utilise trois fois un certain code, et finalement je me suis dit que c'etais bien mieux, et plus clair surtout, de faire une procédure qui éxecutait le code, mais quand j'utilise la fonction, il lance
cette erreur lors de l'execution :
Invalid argument
erreur avec un sendto
Je recopie le code necessaire a la ligne pres pour la procedure et je comprends pas trop... pourquoi j'ai cette erreur !!
on peut trouver mon code a cette page :
http://rafb.net/paste/results/LgyxJ966.html
sinon le voici ici aussi :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 void sendPacketToPeer(struct bfdStateVariables *mySession){ struct packetSerializable *packetSerialized; struct bfdPacket *packet; struct sockaddr_in peer; if ( ( packet = malloc(sizeof(struct bfdPacket)) ) == NULL ) printf("Not enought memory to send a packet.\n"); else{ if ( ( packetSerialized = malloc(sizeof(struct packetSerializable)) ) == NULL ){ printf("Not enought memory to send a serializable packet.\n"); free(packet); } else { initialiseBfdPacket(packet); buildPacket(packet,mySession); host2net(packet,packetSerialized); printf("FD is : %d\n",mySession->fd); if ( ( sendto( mySession->fd, packetSerialized, sizeof(struct packetSerializable), 0, (struct sockaddr *)&peer, sizeof(peer) ) ) < 0 ) { perror("Erreur de l'appel __ 'sendto' "); } free(packetSerialized); } free(packet); } }
Partager