Pb bind pour un serveur avec djgpp/gcc

Guillaume of IUT Messages postés 1 Date d'inscription dimanche 7 décembre 2003 Statut Membre Dernière intervention 6 février 2004 - 6 févr. 2004 à 21:18
neoTHGLF Messages postés 65 Date d'inscription dimanche 7 septembre 2003 Statut Membre Dernière intervention 17 décembre 2007 - 13 févr. 2004 à 13:41
Salut à tous, j'ai un problème. Voici le code du serveur en C. C'est pratiquement l'exemple qui est livré avec les librairies tcp lsck073b. Le probleme est à l'exécution. Le bind foire et le perror m'affiche "No such device <ENODEV>"

/*
* Demo programme for libsocket for DJGPP
* This demonstrates the use of libsocket.
* This is server.
* This file will compile also under Linux.
*
* Copyright 1997, 1998 by Indrek Mandre
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include

void affichage(struct sockaddr_in *ptr)
{
printf("\nFamille : %li\n", ntohl(ptr->sin_family));
printf("Port : %i\n", ntohs(ptr->sin_port));
printf("IP : %s\n", inet_ntoa(ptr->sin_addr));
printf("Longueur : %ld\n", sizeof(&ptr));
}

int main(void)
{
struct sockaddr_in in;
struct sockaddr_in peer_in;
int sock;
char PORT[256];
char MESSAGE[256];
int newsock;
int len;
char buf[256];
char HOST[256];

/*
* Now we read from user on which port he wants the server crawl and
* which message will be sent to clients.
*/

printf ("Entrer l'adresse ip : ");
gets (HOST);

printf ("Entrer le numero de port : ");
gets (PORT);

printf ("Enter message we send to clients: ");
gets (MESSAGE);

/*
* At first we have to create socket.
* After that we bind it on desired port and after that we begin
* to listen it.
*/

memset ( &in, 0, sizeof ( struct sockaddr_in ) );

sock = socket ( AF_INET, SOCK_STREAM, 0 );

in.sin_family = AF_INET;
// in.sin_addr.s_addr = INADDR_ANY; // Remplit mal la structure sockaddr_in au niveau de l'adresse ip vérifiable avec la fonction d'affichage
in.sin_addr.s_addr = inet_addr ( HOST ); // Remplace INADDR_ANY
in.sin_port = htons ( atoi ( PORT ) );

affichage(&in);

if ( ( bind ( sock, (struct sockaddr *)&in, sizeof ( struct sockaddr_in ) ) ) < 0 )
{
perror("\nBIND DE MERDE !!! ");
exit(-1);
}

listen ( sock, 5 );

/*
* Infinite loop.
* We use accept to get new client. The socket is blocking, so accept
* waits while new client arrives. Accept returns the new socket's
* descriptor. peer_in will be filled with the address of the client.
* We receive the message that client send and send our message back.
* After that we close the connection.
*/

for (;;)
{
len = sizeof ( struct sockaddr_in );

newsock = accept ( sock, (struct sockaddr *)&peer_in, &len );

recv ( newsock, buf, 256, 0 );
send ( newsock, MESSAGE, 256, 0 );

printf ("From %s: %s\n", inet_ntoa ( peer_in.sin_addr ), buf );

close ( newsock );
}

return 0;
}

2 réponses

neoTHGLF Messages postés 65 Date d'inscription dimanche 7 septembre 2003 Statut Membre Dernière intervention 17 décembre 2007
13 févr. 2004 à 13:30
Bonjour,
Je ne pense pas que ça vienne de ton programme. Ca doit venir de ta configuration réseau. Désolé, je ne peux pas t'aider plus, je ne vois pas vraiment d'où ça vient. Peut-être que ENODEV est une interface comme eth0. Le programme cherche l'interface ENODEV et ne la trouve pas car elle n'existe pas ? peut-être...
0
neoTHGLF Messages postés 65 Date d'inscription dimanche 7 septembre 2003 Statut Membre Dernière intervention 17 décembre 2007
13 févr. 2004 à 13:41
Bonjour,
Sur groups.google.fr :
"ENODEV (No such device) indicates that the kernel was compiled without a driver for the device in question."
Si ça peut t'aider.
Sinon, la page de recherche, j'ai pas trop regardé dedans peut être trouveras-tu ton bonheur : http://groups.google.fr/groups'as_q=No%20such%20device%20ENODEV&ie=ISO-8859-1&lr=&hl=fr

Sinon, j'ai vu dans un groupe quelqu'un qui utilise DJGPP et qui a le même probleme sur comp.os.msdos.djgpp

@+.
0
Rejoignez-nous