Sign in to follow this  
Followers 0
jvanegmond

DMZ / Port forwarding check

2 posts in this topic

Didn't find anything like this on the forum so I thought it would be worth sharing. Surely someone out there has a use for this since it's one of the more common reasons why I start up uTorrent for their port forwarding check tool.

The method I use from yougetsignal.com isn't officially supported, I think. Might be good to write a service for that yourself and put it online. Let me know if you do and you want other people to use it for free.

$port = InputBox("Port forwarding check", "Enter a port number to see if it can be reached from the web")
If @error Then Exit

$port = Number($port)
ConsoleWrite("Checking port " & $port & @CRLF)

$url = "http://www.yougetsignal.com/tools/open-ports/php/check-port.php?portNumber=" & $port

TCPStartup()

$MainSocket = TCPListen(@IPAddress1, $port)
If @error Then
    MsgBox(0, "Port forwarding check", "Can't check if port " & $port & " is open because it is in use or out of range.")
    Exit
EndIf

Sleep(250)

$handle = InetGet($url, "temp.html", 1, 0)

While 1
    $ConnectedSocket = TCPAccept($MainSocket)
    If $ConnectedSocket >= 0 Then
        MsgBox(0,"Port forwarding check", "Port " & $port & " is open!")
        ConsoleWrite("Port " & $port & " is open!" & @CRLF)
        Exit
    EndIf
    
    If FileExists("temp.html") Then ; Couldn't get this working with InetGetInfo and couldn't bother looking around why (maybe old AutoIt?)
        MsgBox(0, "Port forwarding check", "Port " & $port & " is closed. :(")
        ConsoleWrite("Port " & $port & " is closed. :(" & @CRLF)
        Exit
    EndIf
Wend

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's quite possible that I overlooked something but when I forwarded a port then uTorrent says that port is open but this script says that that the port is closed. Have I misunderstood something?

No, nvm, my bad. Works fine.

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0