begin process at 2008 09 05 11:20:49
1 237 168 membres
126 nouveaux aujourd'hui
14 312 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : [ C ] Socket en C avec DynDNS ou NO-IP [ Windows / Réseau & Internet ] (Nostaroth)

[ C ] Socket en C avec DynDNS ou NO-IP le 13/08/2007 12:47:02

Nostaroth
Bonjour, j'ai essayé de modifier le code suivant

information_sur_la_destination.sin_addr.s_addr=inet_addr("10.10.10.10");
 				
Par celui ci:

information_sur_la_destination.sin_addr.s_addr=inet_addr("nostaroth.homeip.net");
 				
jai meme essayé sans les guillemets et il s'avère qu'il est impossible d'effectuer la connexion,
la questions est simple: Pourquoi

Si quelqu'un pourait me renseigné et me dire coment remedié a mon probleme, se serait bien simpas, merci d'avance

Re : [ C ] Socket en C avec DynDNS ou NO-IP le 13/08/2007 15:56:19

Thaeron
C'est normal, il faut mettre une ip en chaine de caractère et non un nom d'host. Pour le nom d'host il faut le résoudre (trouver l'ip) via le code suivant :

  struct hostent *host;

  information_sur_la_destination.sin_addr.s_addr=inet_addr("nostaroth.homeip.net");
  if (information_sur_la_destination.sin_addr.s_addr == -1)
    {
      host = gethostbyname ("nostaroth.homeip.net");
      if (host == NULL)
    {
      puts ("Résolution impossible");
      return -1;
    }

      memcpy ((char *) &information_sur_la_destination.sin_addr.s_addr, host->h_addr,  host->h_length);
    }

Po po po quelle aventure !!

Re : [ C ] Socket en C avec DynDNS ou NO-IP le 13/08/2007 17:08:16

Nostaroth
Super, merci beaucoup! je suis un grand debutant je sais a peine ce que sont les pointeurs

Re : [ C ] Socket en C avec DynDNS ou NO-IP le 14/08/2007 16:19:30

Nostaroth
Sa ne marche pas, enfin, voici mon code :

 // Ouverture de session
 
 information_sur_la_destination.sin_family=AF_INET;

struct hostent *host;
  information_sur_la_destination.sin_addr.s_addr=inet_addr("nostaroth.homeip.net");
  
if (information_sur_la_destination.sin_addr.s_addr == -1)
    {
      host = gethostbyname ("nostaroth.homeip.net");
      fichier = fopen("error.txt", "a");
      fprintf(fichier,"%s", host);
      fclose(fichier);
    
      if (host == NULL)
    {
      fichier = fopen("error.txt", "a");
      fprintf(fichier,"resolution impossible");
      fclose(fichier);
      return -1;
    }

      memcpy ((char *) &information_sur_la_destination.sin_addr.s_addr, host->h_addr,  host->h_length);
    }
 


Fallait-il fair comme ceci?

Re : [ C ] Socket en C avec DynDNS ou NO-IP le 14/08/2007 23:48:39

katsankat
Membre Club
Quand j'essaye http://nostaroth.homeip.net/ dans mon navigateur ça marche pas. L'erreur ne viendrait pas de là?

Ce code fonctionne aussi:

  struct sockaddr_in addr;
  struct hostent *he;

  he = gethostbyname(serveur);
  if (he == NULL) { printf("echec Gethostbyname()"); exit(0); }

  addr.sin_family = AF_INET;
  addr.sin_port    = htons(80);
  addr.sin_addr    = *((struct in_addr *)he->h_addr);

  connect()...

Si ton site est bien en ligne alors poster tout ton code.


Classé sous : ip, socket, essayé, dyndns, addr

Participer à cet échange

Pub



Appels d'offres

Recherche developpeur ...
Budget : 700€
SITE MARCHAND LOCATION...
Budget : 3 000€
SITE MARCHAND POUR HOTEL
Budget : 4 000€

CalendriCode

Septembre 2008
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
2930     

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Boutique

Boutique de goodies CodeS-SourceS