Jump to content

TCP question


 Share

Recommended Posts

For my script i was able to use TCPConnect and then TCPSend something to the server and its working .

$socket = TCPConnect($ip, $port)

However I am trying to find a way to listen to an existing socket, but TCPListen doesn't work for some reason.

$socket = TCPListen($ip, $port, 5000)

Both of them are using the same IP and port but TCPListen is returning a -1 error

please tell me what i am doing wrong

Link to comment
Share on other sites

Link to comment
Share on other sites

Hi

Code that works if i start the client with autoit, i can receive the packets back

TCPStartup()

$socket = TCPConnect($ip, $port)


ConsoleWrite("SOCKET: "&$socket&@LF)

If $socket = -1 Then Exit


While 1
    $recv = TCPRecv ($socket, 5000)
    If $recv <> "" Then
        ConsoleWrite($recv&@CRLF)
    EndIf
WEnd
TCPShutdown()

Code that doesn't work if the client is already started and talking to the server, can't get a socket

TCPStartup()

$socket = TCPListen($ip, $port, 100)


ConsoleWrite("SOCKET: "&$socket&@LF)

If $socket = -1 Then Exit


While 1
    $recv = TCPRecv ($socket, 5000)
    If $recv <> "" Then
        ConsoleWrite($recv&@CRLF)
    EndIf
WEnd
TCPShutdown()
Edited by d0n
Link to comment
Share on other sites

For my script i was able to use TCPConnect and then TCPSend something to the server and its working .

$socket = TCPConnect($ip, $port)

However I am trying to find a way to listen to an existing socket, but TCPListen doesn't work for some reason.

$socket = TCPListen($ip, $port, 5000)

Both of them are using the same IP and port but TCPListen is returning a -1 error

please tell me what i am doing wrong

Have you tried Kips' Event Driven UDP http://www.autoitscript.com/forum/index.php?showtopic=74325 it makes life a lot easier with TCP. :(

Link to comment
Share on other sites

Just read the freaking help file TCPRecv() page.

Its not that i can't recv, I can't even get a socket to the connection

And the I am not hosting the server, just trying to read some packets sent between THEIR server, and MY client (i think kip's UDF only works with my server/ my client, correct me if i am wrong here, might of missed something in there)

Edited by d0n
Link to comment
Share on other sites

(i think kip's UDF only works with my server/ my client, correct me if i am wrong here, might of missed something in there)

No you are correct. I thought from your first message it was a client-server system you were setting up.

Maybe you should add a bit of detail so everyone is on the same page?

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...