Socket weird behavior

Discussion in 'iOS Programming' started by namanhams, Dec 12, 2011.

  1. namanhams macrumors regular

    Jun 3, 2009
    I have some code like this :
    After every time interval INTERVAL :
    - Create a socket, set its callback method, and send PING message to this socket.
    Actually my code is the modified version of SimplePing (

    The weird thing is :
    - If INTERVAL is big number (Eg, 0.5s), then everything works fine. The callback is called for every packet that is sent.
    - If INTERVAl is small (Eg, 0.02s), then the callback is always called for the first 50 packets. Callback is not called for all later packets.

    I'm not sure but i think there's something special about this number "50". I've run this app many times and it's always the same.
  2. RonC macrumors regular

    Oct 18, 2007
    It might help if you put real code into the post instead.
  3. namanhams thread starter macrumors regular

    Jun 3, 2009

    Thanks for your reply.

    You can download the source code here. Currently, in main.c, the timer is fired every 1 second. Just change it to 0.2 second. You will see that : from the 49th ping, all pings are sent but there's no reply from server.
  4. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    you said, you can download the source code, but i don't see anything neither ^_-
    and people mostly don't just random download code, maybe try find more specific code, and post that here under [ code] tags please =)

Share This Page