Jump to content
Sign in to follow this  
ntbushwick

Check remote TCP Port

Recommended Posts

ntbushwick

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.

Share this post


Link to post
Share on other sites
roy

Look at these network functions:

TCPStartUp()

TCPConnect()

TCPCloseSocket()

TCPShutDown()

Roy :( .

Share this post


Link to post
Share on other sites
kristoff

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" )

Share this post


Link to post
Share on other sites
therks

kristoff, those functions are now included in the beta release. The Dll is no longer necessary for TCP functions.

Share this post


Link to post
Share on other sites
kristoff

Thanks Saunders, Can I have more info please or point me to the right link, do not find anything regarding this :(

TIA

Share this post


Link to post
Share on other sites
kristoff

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

Share this post


Link to post
Share on other sites
MSLx Fanboy

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())

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.