Problems using bind() in KDevelop
Israel Fernández
israel at seg.inf.cu
Mon Sep 2 13:49:32 BST 2002
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'
--
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