Check if IP is in LAN (behind firewalls and routers)

前端 未结 3 925
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 12:40

I\'ve been crawling in the web for about 5 hours now and couldn\'t find a solution for my problem:

My company is developing an educational game and I\'m writing an autou

3条回答
  •  甜味超标
    2021-02-04 12:59

    One thing that you could possibly use is to try and communicate between clients using multicast. Most firewalls and routers would block multicast traffic (and ISPs most definitely), meaning that you wouldn't be able to join a multicast group if no other client is on the lan. A dumb switch would pass on the traffic, a layer 3-switch might block it, or could allow it depending on configuration. Either way, if the layer 3 switch block it, you are probably on different subnets altogether anyway so all other options would fail as well.

    One technology that comes to mind is SSDP ( http://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol ) which would serve your purpose pretty good I believe. That way you don't really need to figure out if you are on a LAN or not, just search for another node that is actively downloading, if you can't find one, start downloading yourself.

    Since SSDP is a standard used in uPnP you would probably be able to find decent implementations you could work with.

提交回复
热议问题