def discoverIGD(max_wait_time=@max_wait_time)
            joinThread()
            if max_wait_time <= 0 then
                raise ArgumentError, "Max wait time must be >= 1"
            end
            sameport = 0
            sameport = 1 if @sameport != false
            @list = MiniUPnP.upnpDiscover(max_wait_time,nil,nil,sameport)
            if @list == nil then
                raise UPnPException.new,"No UPNP Device Found"
            end
            define_finalizer(@list,proc {|o| MiniUPnP.freeUPNPDevlist(o)})
            
            @urls = MiniUPnP::UPNPUrls.new
            define_finalizer(@urls,proc {|o| MiniUPnP.FreeUPNPUrls(o)})
            @data = MiniUPnP::IGDdatas.new
            @lan = getCString()

            r = MiniUPnP.UPNP_GetValidIGD(@list,@urls,@data,@lan,64);
            if r == 0 || r == 3 then
                raise UPnPException.new, "No IGD Found"
            end
            @lan = @lan.rstrip()
            return nil
        end
def discoverIGD(max_wait_time=@max_wait_time)
            joinThread()
            if max_wait_time <= 0 then
                raise ArgumentError, "Max wait time must be >= 1"
            end
            sameport = 0
            sameport = 1 if @sameport != false
            @list = MiniUPnP.upnpDiscover(max_wait_time,nil,nil,sameport)
            if @list == nil then
                raise UPnPException.new,"No UPNP Device Found"
            end
            define_finalizer(@list,proc {|o| MiniUPnP.freeUPNPDevlist(o)})
            
            @urls = MiniUPnP::UPNPUrls.new
            define_finalizer(@urls,proc {|o| MiniUPnP.FreeUPNPUrls(o)})
            @data = MiniUPnP::IGDdatas.new
            @lan = getCString()

            r = MiniUPnP.UPNP_GetValidIGD(@list,@urls,@data,@lan,64);
            if r == 0 || r == 3 then
                raise UPnPException.new, "No IGD Found"
            end
            @lan = @lan.rstrip()
            return nil
        end
This will create a new UPnP instance.  max_wait is the maximum
 time the instance will wait for an answer from the router
 while seaching or it autodiscover to true will start a thread
 on the background to scan the network.  All the other
 functions are safe to be called in the meanwhile, they will
 just wait for the scan to end before operating.
 The variable sameport if set to true will receive UPnP answers from
 the incoming port. It can be usefull with some routers.  Try with
 false, and if it fails try again with true if the firewall allows
 only UPnP ports.
 This method will search for other routers in the network and
 will wait the specified number of milliseconds that can be
 ovveridden by the parameter.  It has currently (ruby 1.9) a
 limitation. As long as thread are cooperative the upnpDiscover
 function will block the ruby implementation waiting for the
 library.  If this will not be solved with ruby 2.0 the
 interface upnp_wrap.c needs to be hacked.  You can avoid to
 call this function if autodiscover is true.  If no router or
 no UPnP devices are found an UPnPException is thrown.