Problems using bind() in KDevelop

Israel Fernández israel at seg.inf.cu
Mon Sep 2 16:25:26 BST 2002


the fact is that sin_addr is a structure of type struct in_addr:
struct in_addr {
	unsigned long s_addr;
}
so change addr.sin_addr = INADDR_ANY by addr.sin_addr.s_addr = INADDR_ANY


El Lun 02 Sep 2002 09:11 AM, escribió:
> Yeah thanks, that helped... but I still can't set addr.sin_addr =
> INADDR_ANY; ... that is how it's explained in the man pages, I'm a little
> confused :)
>
> /Sharky
>
> On Monday 02 September 2002 14:49, Israel Fernández wrote:
> > You must add the & operator in the bind call
> > bind(sock_fd,(struct sockaddr *) &addr,sizeof(addr));
> >
> > addr contains data and you can not convert all the struct in a sockaddr
> > pointer, but you can convert the address of addr to a pointer. ;-)
> >
> > > <code snip from the cpp file of a KDE mini application>
> > > #include <sys/socket.h>
> > > #include <sys/types.h>
> > > #include <netinet/in.h>
> > > #include <arpa/inet.h>
> > >
> > > #include "socktest.h"
> > >
> > > Socktest::Socktest(QWidget *parent, const char *name) : QWidget(parent,
> > > name) {
> > > 	struct sockaddr_in		addr;
> > >
> > > 	addr.sin_family = AF_INET;
> > > 	addr.sin_port = htons(0);
> > > 	addr.sin_addr = INADDR_ANY;		// This is the line where the error
> > > occurs.... sock_fd = socket(AF_INET,SOCK_STREAM,0);
> > > 	bind(sock_fd,(struct sockaddr *) addr,sizeof(addr));
> > > }
> > > <snip end>
> > >
> > > Error message is:
> > > socktest.cpp:31: no match for `in_addr & = in_addr_t'
>
> -
> to unsubscribe from this list send an email to
> kdevelop-request at kdevelop.org with the following body: unsubscribe
> »your-email-address«

-- 
S at lu2
Israel Farnandez Cabrera


-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list