You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

// #include <stdio.h>
// #include <stdlib.h>
// #include <sys/types.h>
// #include <sys/socket.h>
// #include <errno.h>
// #include <netdb.h> /* pour getaddrinfo */
// #include <string.h> /* pour memset */
// #include <arpa/inet.h> /* pour inet_ntop */
// #define DGRAM_MAX 1024 /* taille MAX en réception */
// void usage() {
// fprintf(stderr,"usage: client hostname port\n");
// exit(1);
// }
// int main(int argc, char **argv) {
// struct sockaddr_storage src_addr;
// int s, ret;
// stocklen_t len_src_addr;
// struct addrinfo hints, *result;
// char response[DGRAM_MAX];
// /* Vérification des arguments */
// if(argc!=3){
// fprintf(stderr,"Erreur : Nb args !");
// usage();
// }
// memset(&hints, 0, sizeof(struct addrinfo));
// hints.ai_flags = 0;
// hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
// hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
// hints.ai_protocol = 0; /* Any protocol */
// hints.ai_canonname = NULL;
// hints.ai_addr = NULL;
// hints.ai_next = NULL;
// ret = getaddrinfo(argv[1], argv[2], &hints, &result);
// if(ret != 0) {
// fprintf(stderr, "getaddrinfo : %s\n", gai_strerror(ret));
// exit(EXIT_FAILURE);
// }
// /* Création de la socket IPv4/IPv6 */
// if((s=socket(result->ai_family, result->ai_socktype, result->ai_protocol))==-1) {
// perror("socket"); exit(errno);
// }
// /* Envoi du message */
// if(sendto(s, argv[3], strlen(argv[3]), 0, result->ai_addr, result->ai_addrlen)==-1) {
// perror("sendto"); exit(errno);
// }
// freeaddrinfo(result);
// close(s);
// return 0;
// }