sendto: Invalid argument netbsd

hi all,
I've a program which worked on linux, but after porting on netbsd I take this error..
sent=sendto(sock, buf, buf_siz, 0, (struct sockaddr *) &sin, sizeof(sin));
why?
I did verifying of values which's take function sendto, but they allright.
sent receive -1
Can you post the error. Thanks.
sendto returns -1
at that time it code works very well
1
2
3
4
	if((raw = socket(PF_INET, SOCK_RAW, PPROTO_TCP))== -1) {
                perror("Error creating raw socket: ");
                return 0;
        }
what is errno set to?
what is errno set to?

watch on topic name
sendto: Invalid argument
In first time I use 1 without my_send, but I need doing it from another function like my_send.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
struct sockaddr_in sin; //1
//struct sockaddr_in *sin; //2
malloc(sizeof(struct sockaddr_in));
//i'll take "error: request for member 'sin_family' in something not a structure or union ", therefore I'll use 2..., but I've got segfalt
sin.sin_family = AF_INET;
//sin->sin_family = AF_INET; //2
//Segmentation fault 2
my_send(socket,buffer,&sin); //1
sent=sendto(sock, buf, buf_siz, 0, (struct sockaddr *) &sin, sizeof(sin));
if(sent < 0) {
perror("sendto");
exit(1);
}
void my_send(int s,const char *buf, const struct sockaddr *addr){
int buflen = strlen(buf);
int sent =0;
sent = sendto(s, buf, buflen, 0, (struct sockaddr *)addr,sizeof(addr));
if(sent<0){
perror("sendto");
exit(1);
}// sendto: invalid argument 1 Without my_send function it's works very well, i think what it because somewhere I did a mistake.
}
sizeof(addr) in my_send() is the size of a pointer. You want to pass in the size to my_send().
ok, I fixit
but I've got another problem. There I did post two different methods which's I tried/
1
2
3
4
5
6
7
struct sockaddr_in *sin;
sin->sin_family = AF_INET;
my_send(socket,buffer,sin);
//warning: passing argument 3 of 'my_send' from incompatible pointer type
struct sockaddr_in sin;
sin.sin_family = AF_INET;
my_send(socket,buffer,&sin);

But I seems, what it similar of this...
1
2
3
int number;
int *tommy;
tommy = &number;
Last edited on
Topic archived. No new replies allowed.