Jump to content
Sign in to follow this  
Alexxander

Simple TCP check online or offline script --need help--

Recommended Posts

Alexxander

Hi all i'am learning Autoit and trying to make a simple app that u install it on 2 PCs that is connected over the internet , and it will show every one if the other side is online or not... i'm working on TCP and i cant find a way to detect if the other side is online i tried to send a msg over TCP every one sec and if it received by the other side it say connected and if not it say offline , but i cant get it to work , is there is any other way better than this ? please give me an example cuz i'm a noob thanks in advanced


Share this post


Link to post
Share on other sites
Alexxander

Please post what you have tried thus far, even if it is not working.

 

 

script one (the sender)

TCPStartup()
While 1
$TCPConnect = TCPConnect(@IPAddress1, 403)
TCPSend ($TCPConnect, "hi")
Sleep(1000)
WEnd

script 2 (the receiver)

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

GUICreate("Form1")
 $mylist = GUICtrlCreateList("", 176, 32, 121, 97)

GUISetState()
TCPStartup()
While 1
$msg = GUIGetMsg()

$TCPListen = TCPListen(@IPAddress1, 403)
Do
If GuiGetMsg() = $GUI_EVENT_CLOSE Then Exit
$TCPAccept = TCPAccept ($TCPListen)
Until $TCPAccept <> -1

Do
If GuiGetMsg() = $GUI_EVENT_CLOSE Then Exit
$TCPRecive = TCPRecv ($TCPAccept, 1000000)
Until $TCPRecive <> ""
GUICtrlSetData($mylist, "online")

WEnd

these scripts are not working and it is missing i hope i could fin out a way to detect if the other side is online

i think my way is stupid is there is a proffesional way for doing this ?


Share this post


Link to post
Share on other sites
Alexxander

Are both scripts running on your computer since you use the @IPAddress1 in both scripts?

Jos

 

yes they are working 

for now its ok it the ip is local i can change it later

any ideas about detecting online / offline ?


Share this post


Link to post
Share on other sites
bogQ

i dont see reason why your trying to reconnect on client in every step

when msg is sent if other side is not responding it should return error, putting some time trigger to send msg and check later for reply or for error shud do it

try the link in my sign to see if it can help you about two way communication working with more than one client

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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  

×