Thread: sendto: Invalid argument netbsd

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    77

    sendto: Invalid argument netbsd

    hi all,
    I've a program which worked on linux, but after porting on netbsd I take this error..
    Code:
    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    And you expect us to do what, with one line of code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    I would say the socket argument is invalid at runtime, is it correctly checked earlier in the code? Perhaps it worked on linux because everything went fine in the few cases you used it; or perhaps the ported version introduces some bugs if you changed several things.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    77
    Quote Originally Posted by root4 View Post
    I would say the socket argument is invalid at runtime, is it correctly checked earlier in the code? Perhaps it worked on linux because everything went fine in the few cases you used it; or perhaps the ported version introduces some bugs if you changed several things.
    yes, I change only struct elements, because linux and netbsd sockets differently.
    Either of element has a similar on netbsd socket, but that tcp_h->res1, it's exist only on linux and I was constrained // marked it.
    I've change structure objects like this...
    after on linux
    ip_h->daddr
    tcp_h->source
    before on netbsd
    ip_h->ip_dst.s_addr
    tcp_h->th_sport
    but I cant' find out res or res1 into headers include/netinet/*.h on netbsd
    Furthermore, I find out there similar of problem...
    http://mail-index.netbsd.org/tech-ne...1/03/0001.html
    But I'm confused about that. When I make a tcp packet with data, I should give space for structs ip_h,tch_h and data_h.
    buf_siz = sizeof(struct ip) + sizeof(struct tcphdr)+ sizeof(data) ;
    And I not understand what is meaning he was writing.

  5. #5
    Registered User bboozzoo's Avatar
    Join Date
    Jan 2009
    Posts
    14
    uhhh, given that you mention 'giving space for ip_h, ...' you don't seem to be opening SOCK_STREAM, but rather SOCK_RAW or even PF_PACKET. can you explain why?

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    77
    I use it check, but it executed in successful.
    Code:
    	if((raw = socket(PF_INET, SOCK_RAW, PPROTO_TCP))== -1) {
                    perror("Error creating raw socket: ");
                    return 0;
            }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM
  5. Flood of errors when include .h
    By erik2004 in forum C++ Programming
    Replies: 14
    Last Post: 12-07-2002, 07:37 AM