This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: errors
- From: "Yves Crespin" <Crespin dot Quartz at Wanadoo dot fr>
- To: "Rahul it" <sammas_it at rediffmail dot com>,<gcc-help at gcc dot gnu dot org>
- Date: Mon, 27 May 2002 15:13:52 +0200
- Subject: RE: errors
- Reply-to: <Crespin dot Quartz at Wanadoo dot fr>
// Original code
// For socket, you must indicate the protocol family not the address family
// it's must be PF_UNIX (in some implementations PF_UNIX != AF_UNIX)
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket");
exit(1);
}
//
their_addr.sin_family = AF_INET; // host byte order
their_addr.sin_port = htons(MYPORT); // short, network byte order
// h_addr is only for backward compatibility
// before using an address, you must check the type IPV4 and the size
if (he->h_addrtype!=AF_INET){
// error : wrong type
}
if ((unsigned int)he->h_length==sizeof(struct in_addr)){
// error: wrong size
}
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
// It's depend of implementation !!!
// the only way is to reset the whole struct before
memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct
> -----Message d'origine-----
> De : Rahul it [mailto:sammas_it@rediffmail.com]
> Envoyé : lundi 27 mai 2002 14:48
> À : Yves Crespin
> Objet : Thanks
>
>
> Oh Yups finally I could manage. I am sorry itwas my carelessness,
> I had not included one header file
> netdb.h
> I am really sorry on my part and many many thanks to you
> Shalen
>
> On Mon, 27 May 2002 Yves Crespin wrote :
> >There's no compiler problem on the orginal source!!
> >You can have struct on right-hand part.
> >
> >[blog@linux tmp]$cc -Wall talker.c -o talker
> >[blog@linux tmp]$echo $?
> >0
> >[blog@linux tmp]$./talker host "Hello!"
> >sent 6 bytes to 200.200.25.2
> >[blog@linux tmp]$
> >
> >
> > > -----Message d'origine-----
> > > De : Rahul it [mailto:sammas_it@rediffmail.com]
> > > Envoyé : lundi 27 mai 2002 13:14
> > > À : Yves Crespin
> > > Objet : Re: RE: errors
> > >
> > >
> > > Yes! I think its error in the original code only
> > > Compiler Version
> > >
> > > chhabra@noix{chhabra} 1001 : gcc --version
> > > 2.95.2
> > >
> > > the source code of the program is here
> > >
> >http://www.ecst.csuchico.edu/~beej/guide/net/examples/talker.c
> > >
> > > I think there is a problem with the line
> > > their_addr.sin_addr = *((struct in_addr *)he->h_addr);
> > >
> > > I have asked the person who has written this code but he has
> >not
> > > replied.
> > >
> > > Can you compile and run this code.
> > > Note this is the code of talker.c. You will have to run the
> >code
> > > listener.c as well on some other machine as the author of the
> >code
> > > says.
> > >
> > > "And that's all there is to it! Run listener on some machine,
> >then
> > > run talker on another. Watch them communicate! Fun G-rated
> > > excitement for the entire nuclear family!"
> > >
> > >
> > > code for listener.c
> > >
> > >
> >http://www.ecst.csuchico.edu/~beej/guide/net/examples/listener.c
>
> > >
> > > I am very much thankful to you.
> > > Yups ! regarding errors in the openssl, I think that there is
> >a
> > > problem with the version. The Sys Admin here is absent for
> >days, I
> > > will ask him. People from the openssl and gcc have kept me
> >going
> > > and now I am doing quite good in my project. I am 21, from
> >India
> > > and an actually doing my summer internship here in France .
> > >
> > > Thanks a Lot
> > > Shalendra
> > > _________________________________________________________
> > > Click below to visit monsterindia.com and review jobs in India
> >or
> > > Abroad
> > > http://monsterindia.rediff.com/jobs
> > >
> >
>
> _________________________________________________________
> Click below to visit monsterindia.com and review jobs in India or
> Abroad
> http://monsterindia.rediff.com/jobs
>