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
|
#include ....
char texteudpport[]="Numeros du port UDP :";
char *strportudp=NULL;
int main(void)
{
int udpport;
struct sockaddr_in si_other;
int s, i, slen=sizeof(si_other);
strportudp = RecupChemin(texteudpport);
udpport=atoi(strportudp);
if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
diep("socket");
memset((char *) &si_other, 0, sizeof(si_other));
si_other.sin_family = AF_INET;
si_other.sin_port = htons(udpport);
if (inet_aton(ipcentrale, &si_other.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
exit(1);
}
sendto(s, trame, 29, 0, (struct sockaddr *)&si_other, slen)==-1
..
...
} |
Partager