Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pinging several IPs crahes

Discussion in 'Multiplayer' started by susdorf, May 29, 2009.

  1. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Dear Unity Community,

    I have the same problem like in
    UDP Broadcast.

    So I decided to implement a pinging approach to find other local game server or clients. But when pinging several ip addresses in a loop, Unity 2.5 crahes immediately.

    For example:

    Code (csharp):
    1.  
    2. void Update()
    3. {
    4.   for( int i=0; i<10; i++ )
    5.   {
    6.     string lip = "192.168.2." + countIP++;
    7.     Ping p = new Ping(lip);
    8.     Debug.Log("Ping: " + lip);             
    9.   }            
    10. }
    11.  

    Code (csharp):
    1.  
    2. Log is:
    3. Ping: 192.168.2.0
    4. ...
    5. Ping: 192.168.2.9
    6. Ping: Error performing ICMP transmission. Possibly because of a timeout
    7.  
    Because of a timeout Unity crashes?
    When there is a brave programmer out there solved this "LAN Lookup without a master server" problem, please let me know...

    Thanks in advance...
     
  2. Kai

    Kai

    Joined:
    May 28, 2009
    Posts:
    24
    Are you crashing to desktop when this happens? If so, I'm running into the same problem except that I'm pinging the same server repeatedly (every 30 seconds) to poll for latency.

    This kind of sucks. I'm going to try and use the BCL implementation and see what happens.
    http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

    I have a sneaking suspicion, however, that U3D may already use the Ping class from the Mono base class library and that the Mono implementation has some weird bug.

    Gonna cross my fingers and see what happens.
     
  3. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Yes it crashes to Desktop.
    I was looking for other solutions, but could nothing find that was stable enough to ping several time, several servers.

    So I disabled Pinging... perhaps sometime there will be a solution for this problem.
     
  4. Kai

    Kai

    Joined:
    May 28, 2009
    Posts:
    24
    Yeah. This is definitely busted. I'm guessing it has something to do with the threading behind the scenes. Too bad it doesn't work.
     
  5. MihkelT

    MihkelT

    Joined:
    Sep 18, 2014
    Posts:
    21
    Necropost but I had the same problem and didn't fund much discussion on this.

    Unity 2109.11.1 crashed when recently over 1024 pings had been created with new Ping. The solution was to use ping.DestroyPing() on the old ones it seems.