Sign in to follow this  
Followers 0
JRowe

TCP Help

2 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

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