Jump to content

TCP Help


Recommended Posts

I want to connect to port 3601, and maintain the connection.

I want to be able to send ASCII messages to port 3601, and receive messages from the same.

With the code I've been using, it seems the send only works once, and every message thereafter isn't firing.

Can anyone point out why this is only working once, and not after the first connect/send/receive session?

CODE
HotKeySet('a', '_Test') ; Set up an A hotkey to send the message

HotKeySet('{ESC}', '_Close') ; Call a close function to close the script when someone presses escape

TCPStartup() ; Initialize the TCP functions/library

$Socket = TCPConnect(@IPAddress1, 3601) ; Connect to the server

If @error Then ; If no connection is made, the server probably is not running, or another error occurs, give an error message to the user

MsgBox(0x20,"Connection error", "Unable to connect to " & @IPAddress1 & ":7000")

Exit ; Close the script

EndIf

While 1

$sData = TCPRecv($Socket,3601)

If $sData Then ; There has been some data sent.

MsgBox(0, "Message Received", $sData)

EndIf

WEnd

Func _Test()

TCPSend($Socket,"(+ 1 4)") ; Send the data

EndFunc

Func _Close()

TCPCloseSocket($Socket) ; Close the socket to the server

TCPShutdown() ; Deinitialize the TCP functions/library

Exit ; Close the script

EndFunc

Link to comment
Share on other sites

There wasn't anything wrong with the AutoIt side, I just needed to include an escape character at the end of the SubL query.

Everything seems to be working fine :)

I'm going to test and see more of how this works.

Edited by Jrowe
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...