Sign in to follow this  
Followers 0
Xand3r

TCPConnect always returning a socket

15 posts in this topic

TCPStartup()
For $i=1 To 65000
    $con=TCPConnect("127.0.0.1",$i)
    If $con=-1 Then
        MsgBox(0 , "" , $i)
    Else
        
        If Not Mod($i,100) Then ToolTip($i&@TAB&":"&@TAB&$con,0,0)
        
        TCPCloseSocket($con)
        
    EndIf
Next

So this script in au3 form does not show even one msgbox for me but if compiled works fine

any ideea what could cause this behavior because earlyer today the script worked fine (well not this one this is a mock-up :P)

my environment : xp vista sp1

autoit version : 3.2.12.1


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites



dude i know what my script does but i think you missunderstood my problem

i'm 100% sure that not the script itself is the problem because when i run it in au3 form all my ports seem to be open(they are not!) and if i run it in compiled form it works fine (msgbox on ports that are open)


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

For $i=1 To 65000 - that would take like forever to check doing it this way.

How long did it take you to check all ports?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

2-3 mins


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

2-3 mins

That is strange. Try this:

HotKeySet("{Esc}", "_Exit")

$start = TimerInit()

TCPStartup()
For $i=1 To 65000
    $con=TCPConnect("127.0.0.1",$i)
    If $con=-1 Then
       ToolTip("Port:" & @TAB & @TAB & "$con" & @CRLF &  $i & @TAB & ":" & @TAB & $con & @CRLF & @CRLF & "  Press ESC to exit")
    Else
       MsgBox(0 , "$con = " & $con, "$port " & $i) 
      TCPCloseSocket($con)        
    EndIf
Next

Func _Exit()
    ToolTip("")
    MsgBox(0 , "Elapsed time", TimerDiff($start) / 1000 & " sec" & @CRLF & @CRLF & "Number of tested ports: " & $i)
    Exit
EndFunc

I get one port per second. And you, apparently, 1000. Is it?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

He could have changed the TCPTimeout option?

Anyway the script worked as it was supposed to when I was running it in either script form or compiled for me.

Share this post


Link to post
Share on other sites

He could have changed the TCPTimeout option?

Anyway the script worked as it was supposed to when I was running it in either script form or compiled for me.

What is set by TCPTimeout option?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I thought it changed how fast the TCPConnect and TCPSend functions time out but apparently not. In my tests I get a port a second as well.

My code...

Opt("TCPTimeout",20) 

TCPStartup()

$ip = "127.0.0.1"

For $i = 1 To 65000
    $time = TimerInit()
    $con = TCPConnect($ip, $i)
    If $con <> -1 Then
        MsgBox(0, "", $i)
        TCPCloseSocket($con)   
    EndIf
    MsgBox(0, "", round(TimerDiff($time)) / 1000)
Next

Func OnAutoItExit()
    TCPShutdown()
EndFunc
Edited by SoulA

Share this post


Link to post
Share on other sites

i did not touch the tcp timeout and in compiled form i get about 1-2 ports a second(because they timeout)

in au3 form i get 1000/second because THE SOCKETS CONNECT but it seams like you guys don't understand what i'm saying

here's the noobes form i can say it in:

tcpconnect on a closed port returns a socket number :|


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

i did not touch the tcp timeout and in compiled form i get about 1-2 ports a second(because they timeout)

in au3 form i get 1000/second because THE SOCKETS CONNECT but it seams like you guys don't understand what i'm saying

here's the noobes form i can say it in:

tcpconnect on a closed port returns a socket number :|

I think we know what you're saying. The problem is (your problem is) that other people don't get the same result. I don't for example. So complaining that people aren't listening to you or don't understand seems stupid when you don't listen to or don't understand their replies.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

martin for the president!


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I copied and pasted into scite. Hit F5. I get a message box for every port, firewall off.

Edited by scriptjunkie

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

ok i'm sorry but you all presumed i was doing something wrong :|

a couple of days ago the script worked just fine

and i had a simple question

how is it possible that when you TCPConnect to the loopback ip and a port that is closed you get a socket :| (firewall off!)

[qoute]

I get one port per second. And you, apparently, 1000. Is it?

Edited by TheMadman

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

ok i'm sorry but you all presumed i was doing something wrong :|

a couple of days ago the script worked just fine

and i had a simple question

how is it possible that when you TCPConnect to the loopback ip and a port that is closed you get a socket :| (firewall off!)

I don't know.

I had a problem 2 days ago with ZoneAlarm. After about 5 minutes I couldn't get internet access to sites, though my email worked and ftp worked. The only way I could connect again was to reboot and then I got another 5 mninutes. Same problem if I turned off my firewall. After trying lots of very complicated advice I uninstalled ZoneAlarm and reinstalled it and the problem has gone. I suspect, but don't know, that my problem was caused by (another) duff ZoneAlarm automatic update.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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