Sign in to follow this  
Followers 0
d0n

TCP question

11 posts in this topic

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

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

bump anyone help?

Share this post


Link to post
Share on other sites

Just read the freaking help file TCPRecv() page.


♡♡♡

.

eMyvnE

Share this post


Link to post
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. :(

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

=,= """"

You can't just "read some packets" between THAT server and YOUR client directly with autoit.

And each port could only assign to 1 program.

what is it you are trying to do??

Edited by MiserableLife

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

yes i guess you can call it a packet sniffer, is this possible with autoit?

EDIT: Got it working with WinPcap, thank you!

Edited by d0n

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