using icmp in a c code

This is a discussion on using icmp in a c code within the C Programming forums, part of the General Programming Boards category; Hy All, When I use icmp in my c code it works fine. As I moved it into antother computer ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    6

    using icmp in a c code

    Hy All,

    When I use icmp in my c code it works fine.

    As I moved it into antother computer I received nothing back. Or I received back echo messages if I started a "ping "something"" command from the consol. During the ping command was running my code was working fine.

    I thought it is because of the firewall, but it is not probably.
    I use own socket and create ip and icmp packeges. What is the common point in case of ping and in my application? What does ping set what I did not?

    Do you have any idea?

    Tamas

  2. #2
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Working on Linux / Unix? Ping is often installed "setuid root", which means it has root privileges for anything it does. Your program probably doesn't. On Linux, you need to have root privileges to send ICMP messages (because they can be used to terminate connections and all sorts of other trouble if you're not careful).

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    6
    Quote Originally Posted by ledow View Post
    Working on Linux / Unix? Ping is often installed "setuid root", which means it has root privileges for anything it does. Your program probably doesn't. On Linux, you need to have root privileges to send ICMP messages (because they can be used to terminate connections and all sorts of other trouble if you're not careful).
    I am in linux.
    I have no problem with privileges.
    It is interesting. I copied my code from my application into a new emty code and it is works. It seems me my application does not send out my messsages, because as I run the single code I receive messages in my application too. So the receiving is good in my code.

    My application uses another socket to manage that application. Maybe ican it cause problem? I receive the same return messages when I use my application or the single code.

    Tamas

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    6
    Hello, I got here:

    Code:
    main(){
    
    //my code
    
    }
    the above works and the below does not:
    Code:
    main(){
    foo()
    }
    
    foo(){
    //my code
    }

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    6
    and the erros is not during the compiling. it sends a message and waits for it without success as the normal code does. But i think it does not send message., however I receive no error and no errno.

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    6
    Hy,

    I found the source of the problem. I think it is with the optimalization during the compile process. As I change it in the single file I can reproduce the same error. Without optimalization it does not work. But i cannot optimalize it in my another application yet.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tcp and icmp Question
    By invisibleghost in forum Networking/Device Communication
    Replies: 9
    Last Post: 08-12-2005, 06:23 AM
  2. Traceroute using UDP and ICMP
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-09-2002, 08:09 PM
  3. Traceroute using UDP + ICMP
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 08-05-2002, 11:50 AM
  4. Icmp
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2001, 12:37 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21