HZNM.COM
welcome to my space
X
Search:  
 HOME   sendto() and EACCES
sendto() and EACCES
Published by: admin 2009-01-09
Welcome to:hznm.com

  • Cal Poly Central UNIX man pages : udp (7)::
    is normally used with the sendto(), sendmsg(), recvfrom(), and recvmsg() calls EACCES A bind() operation was attempted with a reserved port number and the
    http://www.calpoly.edu/cgi-bin/man-cgi?udp+7
    HOME
    Hi,

    in some program i wrote, im getting a EACCES (permission denied) whenever i run it.

    [EACCES]
    Search permission is denied for a component of the path prefix; or write access to the named socket is denied.

    Now, i know what could cause this error, but i cant find a problem in my code....
    I mean, any function in some program should be able to write to a socket arent they?

    So, what is the solution for this error?
    im not posting the code since its pretty big... but if you really need the code, just ask it ;)

    thanks,
    encrypted


  • D'oh! I see now you mentioned that right in the main thread
    subject... ;-) I wasn't paying attention, I guess... ;-)

    Hmmmm... The only thing I can think of is that maybe you're
    trying to send messages to a broadcast address without having
    SO_BROADCAST set...


  • sendto() is failing with EACCES


    encrypted


  • What function exactly is failing with EACCES??


  • saddr.s_addr = inet_addr(argv[1]);
    daddr.s_addr = inet_addr(argv[2]);


    Um, based on the above command-line, argv[1] and [2] are
    The GNU C Library - Sockets::
    A Linux Help site providing categorized and searchable Linux Help files, Linux Howtos, EACCES. You do not have permission to access the requested address.
    http://www.linuxselfhelp.com/gnu/glibc/html_chapter/libc_16.html
    HOME
    OpenSS7: Documentation: Man Pages: Manpage of LISTEN::
    Manual Page and the socket file descriptor does have O_NONBLOCK set, sendto() will fail. [EACCES]
    http://www.openss7.org/man2html?sendto(3)
    HOME
    "-P" and "T", respectively... So, both inet_addr() calls will be
    failing; and, the documented failure return is -1, which is equivalent
    to the limited broadcast address 255.255.255.255... So, yes, you
    ARE attempting to send to a broadcast address without
    SO_BROADCAST sent... ;-)

    What you really want there is:


    saddr.s_addr = inet_addr(argv[optind]);
    daddr.s_addr = inet_addr(argv[optind+1]);


    Of course, you'd want to perform checks first to make sure that
    optind was sufficiently less than argc, too... (And, of course, the
    same thing applies for reading the port numbers, too...)

    And, in your getopt() loop, it looks like you've got the nested
    switch()'s commented out, so "protocol" and "tcp_bit" are never
    getting set... Also, those nested switches are missing "break"s
    after ever case... And, you want to switch() on "*optarg", I think...


  • Well, im pretty sure im not sending to a broadcast address

    here is the source after all ;)
    http://home.planet.nl/~west3142/n.c


    bash-2.05b# ./n -P T -c S 192.168.168.252 62.131.125.3 9182 80
    Done protocol
    T
    Done TCP BITZ
    2.5.42: accessfs 1/3: new networking hooks [LWN.net]::
    Debians election season: old firmware and new contributors return -EACCES; + + return 0; +#else + return -EACCES; +#endif +} + +static
    http://lwn.net/Articles/12588
    HOME
    SGI TPL View (3 mq_open)::
    SGI Technical Publications Library following conditions are true: [EACCES] The message queue does not exist and [ EACCES] The message queue exists, but
    http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?cmd=getdoc50&db=man&fname=3+mq_open
    HOME
    S
    Ok, done getopts
    Done atoi-ing port numberz
    Done Sin family
    Done sin port
    Done sin addr
    Done memsetting sin zero
    Done getuid
    Done setting packety_size
    Packet size iz: 40 en 40
    Done setting setsockopt in TCP
    Just charred packet
    Malloced packet
    INitialised headers
    Done zerooing packet
    Done fillin in pseudo hdr
    sendto_in_tcp: Permission denied
    bash-2.05b#

    192.168.168.252 is the intern ip address of my computer.
    62.131.125.3 is the router that connects me to the internet.

    All the text that it prints is for me to see if it goes well ;)

    Thanks,
    encrypted


  • Um, based on the above command-line, argv[1] and [2] are
    "-P" and "T", respectively... So, both inet_addr() calls will be
    failing; and, the documented failure return is -1, which is equivalent
    to the limited broadcast address 255.255.255.255... So, yes, you
    ARE attempting to send to a broadcast address without
    SO_BROADCAST sent... ;-)
    hehe lol 8)
    thanks for that

    it works now, so im quite happy :D
    allthough theres still something that doesnt work the way i want it.....

    its about this part:

    case 'c': switch(optarg)
    {
    case 'S': tcp_bit = TH_SYN; break;
    case 'A': tcp_bit = TH_ACK; break;
    case 'R': tcp_bit = TH_RST; break;
    case 'P': tcp_bit = TH_PUSH; break;
    case 'F': tcp_bit = TH_FIN; break;
    case 'U': tcp_bit = TH_URG; break;
    default: usage(NAME);
    }
    check = 1; break;
    case 'P': switch(optarg)
    {
    case 'T': protocol = 1; if( check != 1 ) usage(NAME); break;
    case 'U': protocol = 2; break;
    case 'I': protocol = 3; break;
    default: usage(NAME); break;
    }
    break;

    When i compile it, it says:

    Switch quantity not an integer

    i know optarg is a char variable but i thought you could switch any kind of variable....
    do you know how i can make it compile?
    Because now im using instead of S,A,R,P,F and U, 1 2 3 4 5 and 6 to refer to the control bits, but the letters is more understandable..

    thanks,
    encrypted


  • No, "optarg" is not a char; it's a "char*", ie: a string... You want
    to switch on "*optarg" or "optarg[0]"... (Which I also mentioned
    in the last sentence of my last post... ;-))


  • ahhh i see,
    now it becomes clear to me ;)

    anyway thanks (again)

    encrypted





  • How much does getting a small tattoo on your hip/stomach hurt?
    Do anyone else have an itchy anus? ?

    You are looking at:hznm.com's sendto() and EACCES, click hznm.com to home
  • why they show the llws
  • kenntomasch v bbc on f365
  • a really stupid question about the shootout on dish
  • ad ideas for mls world cup
  • monday night soccer
  • 223 million in saving a year if epl operates like nba mlb nfl nhl
  • fox sports regional epl matches
  • vote for metro mascot
  • romey at it again
  • soccernet com reports the second coming
  • what happened to jamie trecker
  • dirty laundry only for u s coverage
  • an embarrassment of riches
  • average salary for epl nba mlb nfl nhl mls wnba afl etc
  •  
  • the magical echo chamber references to bigsoccer in other places
  • schevchenko on sportscenter commercial
  • visa in mastercard out as world cup sponsor
  • variety real madrid has show for kids soccer dads
  • la liga
  • deadspin
  • article broadcasting rights for world cup in n america
  • gatorade u s soccer commercial
  • new york foosball festival
  • new neilsen market size data
  • john norris is a soccer fan
  • the official i don t give a crap what semi famous doofuses are soccer fans thread
  • real madrid on tv
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 hznm.com        Site made:CFZ