Jump to content

TCPListen


d0n
 Share

Recommended Posts

Dim $IP = @IPAddress1
Dim $nPORT = 4098
Dim $IP2 = "65.209.65.21"
$MainSocket = TCPListen($IP2, $nPORT)

why doesn't it listen to this IP address??

this is only a part of the example code from autoit

i am still trying to learn how to use TCP stuff :S

Link to comment
Share on other sites

Assuming that the IP address listed is actually assigned to your computer and the port is not already in use, you could do the following:

Dim $IP = @IPAddress1
Dim $nPORT = 4098
Dim $IP2 = "65.209.65.21" ;Using a variable such as @IPAddress2 might be better
TCPStartup()
$MainSocket = TCPListen($IP2, $nPORT)
If $MainSocket == -1 Then
    MsgBox( 0, "TCP Error", "Error Listening on TCP" & @CRLF & "@error = " & @error )
    Exit
EndIf
While 1
    $Socket = TCPAccept($MainSocket)
    If $Socket >= 0 Then
        $recv = ''
        While $recv = ''
            $recv = TCPRecv($Socket, 10000)
        WEnd
        ;Do something here based on the request
        ConsoleWrite($recv)
    EndIf
WEnd
Edited by Gabburd
Link to comment
Share on other sites

Ok not really sure what you mean by "assigned to your computer"

but all i want to do is intercept all the incoming packets from this game to the server thing so i can read what is happening

how should i go about and do that?

Link to comment
Share on other sites

Ok not really sure what you mean by "assigned to your computer"

but all i want to do is intercept all the incoming packets from this game to the server thing so i can read what is happening

how should i go about and do that?

Just telling most of the game packets are deeply encrypted.
Link to comment
Share on other sites

how do i know which @IPaddress(number) to pick from tho?

EDIT: and not so much as to intercept but just read all the packets that are sent from that ip

Edited by d0n
Link to comment
Share on other sites

If you have more than one IP Address than you are on more than one network.

Most likely you'll want to use the same one you would use to access your internet connection, unless you are on a seperate LAN or VPN in which case you'll want to use that one.

Edited by Gabburd
Link to comment
Share on other sites

Dim $IP = @IPAddress1
Dim $nPORT = 4099
Dim $IP2 = "65.209.65.21"


; Start The TCP Services
;==============================================
TCPStartUp()

; Create a Listening "SOCKET".
;   Using your IP Address and Port 4099.
;==============================================
$MainSocket = TCPListen($IP2, $nPORT)
MsgBox(0, "", $MainSocket)

so i tried this but

msg box gives me -1 which means something went wrong?

Link to comment
Share on other sites

msg box gives me -1 which means something went wrong?

That means that either the IP address you used is not assigned to your computer, or the port is already in use by another program.

Like I said you aren't going to be able to intercept packets with TCPListen

Link to comment
Share on other sites

  • 5 months later...

... If someone is using a Router how do you automatically detect which IP to listen on (like so many major server applications do) ?

I mean sometimes (for non-router users?) the IP is @IPAddress1

other times it has to be 192.168.1.101 or some obscure private IP (that the router assigns?)

So, how do I automatically find the IP that will allow me to have a listening port open to the internet - despite what form of connection the user has. (since @IPAddress1 apparently using usable in some circumstances)

I am tempted to just try every @IPAddress# and attempt connections remotely somehow upon binding... But that seems out-of-the-way given Big programs do it automatically.

( I am currently using a User prompt to input an IP to match their configuration )

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
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
 Share

  • Recently Browsing   0 members

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