Jump to content

Check remote TCP Port


Recommended Posts

I am not trying to port scan servers. I just need to verify a port on my server is always available, so that my application can always connect to it. How can I use autoit to check to see if a specifc port is listening on a server?

Thanks.

Link to comment
Share on other sites

Hi,

Download AU3Xtra.dll from Larry's web, see examples in the zipped file

Something like :

$dest="bumper"
$port = "8080"
DLLCall( "AU3Xtra.dll", "int", "TCPStartUp" )

$var = DLLCall( "AU3Xtra.dll", "int", "TCPNameToIP", "str", $dest, "str", "" )

$socket = DLLCall( "AU3Xtra.dll", "int", "TCPConnect", "str", $var[2], "int", $port )
If @error Or $socket[0] < 0 Then
Msgbox(0,'PORT STATUS',"NOT OK" )
else
Msgbox(0,'PORT STATUS', "OK" )
Endif

DLLCall( "AU3Xtra.dll", "int", "TCPShutDown" )
Link to comment
Share on other sites

Oppss !

Actually...........Really much easier : :"> ..and easily affordable :(

Require beta 31148 :(

#include <C:\Scripts\AutoItV3\beta311-48\include\GUIConstants.au3>
; Start The TCP Services
;==============================================
TCPStartUp()
;CLIENT!!!!!!!! Start SERVER First... dummy!!
$g_name = "4test"

$IP = TCPNameToIP($g_name)
msgbox(0,"NAME ",$IP)
; Connect to a Listening "SOCKET"
;==============================================
$socket = TCPConnect( $IP, 80 )
If $socket = -1 Then
msgbox(0,"PORT"," GO FISHING PORT IS CLOSED ")
else
msgbox(0,"PORT"," PORT OPEN ")
Endif

Looking forward this release of AutoIt in production, great tx to dvpt team

Edited by kristoff
Link to comment
Share on other sites

Don't forget to close the socket you created (sorry, I have to close anything I open, I'm anal retentive about that :().

The beta version can be found in the Developers forum, under 3.1.1++ topic.

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...