Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4964 connectés 

 


Dernière réponse
Sujet : [C/socket] config sous linux
karlkox un " struct sockaddr_in *sock " reglera surement ton problème, bon codin' !

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
karlkox un " struct sockaddr_in *sock " reglera surement ton problème, bon codin' !
Roswell_ :bounce:
Roswell_ :bounce:
Roswell_ J'ai fait un prog qui marche parfaitement chez-moi sous Linux, mais quand je veux le compiler chez mon hébergeur également Linux. Il me sort cette erreur:
get.c:93: storage size of `sock' isn't known
 
qui correspond à cette ligne ou je déclare sock:
struct sockaddr_in sock;
 
Vous voyer qqchose à faire?
 
Vla le code que j'utilise pour me connecter:

Code :
  1. int main(int n, char ** argv)
  2. {
  3.                 char *requette;
  4.                 int connexion, connexion_service;
  5.                 int lecture,fd;
  6.                 struct sockaddr_in sock;
  7.                 struct hostent *host;
  8.                 // config normale?
  9.                 if(n<4)
  10.                 {
  11.                         perror("get <host> <page> <destination>" );
  12.                         exit(-1);
  13.                 }
  14.                 requette=makeRequette(argv[2]);
  15.                 // Création Socket
  16.                 if ((connexion=socket(AF_INET,SOCK_STREAM,0))==-1)
  17.                 { perror("Erreur création socket" ); exit(1);}
  18.                 // Informations Hote
  19.                 bzero(&sock,sizeof(sock));
  20.                 if (!(host=(struct hostent *)gethostbyname(argv[1])))
  21.                 { perror("Erreur hostname" ); exit(1); }
  22.                 // Prise de connection
  23.                 bcopy((const char *)host->h_addr, (char *)&sock.sin_addr, host->h_length);
  24.                 sock.sin_family=AF_INET;
  25.                 sock.sin_port=htons(80);
  26.                 puts("connexion" );
  27.                 if ((connexion_service = connect(connexion, (struct sockaddr *) &sock, sizeof(sock)))==-1)
  28.                 { perror("Erreur connect" ); exit(1);}


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)