Jump to content

Recommended Posts

Posted

hi all

how can i detect if another script is online ?

i tried this :

 

sender code:

TCPStartup()
$TCPcon = TCPConnect (@IPAddress1, 1234)
While 1
TCPSend($TCPcon, "hi")
WEnd

receiver code: 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Form1", 100, 222)
$Mainlist = GUICtrlCreateList("", -1,-1, 615, 227)
GUISetState()

TCPStartup()
$TCPlisten = TCPListen(@IPAddress1, 1234)
$TCPaccept = TCPAccept($TCPlisten)

While 1
$GUImsg = GUIGetMsg()
If $GUImsg = $GUI_EVENT_CLOSE Then Exit
$TCPRecv = TCPRecv($TCPaccept, 99999999)
Do
$TCPaccept = TCPAccept($TCPlisten)
Until $TCPaccept <> -1

Do
GUICtrlSetData($Mainlist , "")
Until $TCPRecv <> ""
GUICtrlSetData($Mainlist , $TCPRecv)
WEnd

in receiver code: 

i cant understand what is happening when i use "DO" inside "While loop" and why tcp accept and tcp receive will not work when i remove the DO although there is while that supposed to make it always running

and why the close button is not closing the script

in sender code:

i know that i'm doing the connection wrong i must not use while

but i'm confused what i must use to tell the other side that i'm connected so im listed in his list ?

 

please help me this is the first time i use tcp

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
  • Recently Browsing   0 members

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