Sign in to follow this  
Followers 0
Kuram

Sync over network/internet?

11 posts in this topic

I've searched around a bit and could not find any information so here I am asking:

I was wondering if it possible to have 2 separate scripts sync up over the internet or a network (although preferably internet).

For example, me and my friend run the same script, however due to latency the synchronization of both drifts apart over time, which isn't good for the script when it is suppose to run for 8 hours+ (assume all actions must be performed at the same time). Is there a way to have it, every so often, do a sleep command conditional on both scripts arriving at the same point (kind of like the lead script stops and waits for the other to catch up)?

Thanks for help.

Share this post


Link to post
Share on other sites



Is this for a game?

Yeah. Does that change if it's possible or not? I dont exactly see how...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

yes you can.

just post your question again as not related to a game and i will help you out.

secondarily... does anyone know why no game automation is allowed...

Edited by supadodger

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yes you can.

just post your question again as not related to a game and i will help you out.

secondarily... does anyone know why no game automation is allowed...

Well it's not only for games but that was one scenario. It just seems a bit arbitrary to have to make a new thread with the exact same question. Let's just say if I wanted to start a timer, and start it at different times on both computers, it would reach a point at which 1 computer pauses until the other catches up, ie i'm using it to test the latency between our computers as a method of checking connection speed, using a timer while its paused to determine the time differentiation (without simply pinging in the cmd window) so that I can save each output in a txt file to determine both the connection speed, and how much slower/faster it is a different times of the day as a mean value. I know how to do the calculations, i just dont know if both computers can actually connect to each other and bounce info off one another.

going through the faq, would it perhaps have something to do with the udpsend or udpopen commands?

Edited by Kuram

Share this post


Link to post
Share on other sites

Well it's not only for games but that was one scenario. It just seems a bit arbitrary to have to make a new thread with the exact same question. Let's just say if I wanted to start a timer, and start it at different times on both computers, it would reach a point at which 1 computer pauses until the other catches up, ie i'm using it to test the latency between our computers as a method of checking connection speed, using a timer while its paused to determine the time differentiation (without simply pinging in the cmd window) so that I can save each output in a txt file to determine both the connection speed, and how much slower/faster it is a different times of the day as a mean value. I know how to do the calculations, i just dont know if both computers can actually connect to each other and bounce info off one another.

going through the faq, would it perhaps have something to do with the udpsend or udpopen commands?

if it was me i would just make both scripts stop every 15 minutes on the minute and sleep for 1 minute.

that would probably be the simplest.

at the beginning of the script have you both add a start time so they are syncing at the exact same time...

Share this post


Link to post
Share on other sites

if it was me i would just make both scripts stop every 15 minutes on the minute and sleep for 1 minute.

that would probably be the simplest.

at the beginning of the script have you both add a start time so they are syncing at the exact same time...

Hmmm how do you add a specific start time then?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hmmm how do you add a specific start time then?

$Hour = InputBox("","Start Time In Format 12:00")
if @Hour > 12 Then
$RealHour = @Hour -12
Else
    $RealHour = @HOUR
    EndIf
$minute = @Min
While $RealHour & ":" & $minute <> $Hour
    Sleep(100)
    TrayTip ("",$hour & @CRLF & $REalHour & ":" & @Min,30000)
Wend

Then at the end of the mainloop put

$Minute = $Minute + 5
if $minute > 60 Then $Minute = 5
EndIF
While @Min <> $Minute
Sleep(100)
Wend

that way every loop they both sleep until the next batch.

you can change the 5s to anything you want...

Edited by supadodger

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

$Hour = InputBox("","Start Time In Format 12:00")
if @Hour > 12 Then
$RealHour = @Hour -12
Else
    $RealHour = @HOUR
    EndIf
$minute = @Min
While $RealHour & ":" & $minute <> $Hour
    Sleep(100)
    TrayTip ("",$hour & @CRLF & $REalHour & ":" & @Min,30000)
Wend

Then at the end of the mainloop put

$Minute = $Minute + 5
if $minute > 60 Then $Minute = 5
EndIF
While @Min <> $Minute
Sleep(100)
Wend

that way every loop they both sleep until the next batch.

you can change the 5s to anything you want...

This is kinda dependent on both computers having exactly the same system time. There is no way via direct connection? I was thinking of using UDPopen, UDPsend and UDPrecv at the end of each cycle, but I cant think of a way to determine if the other computer received it. Like, you can send a string through a socket, and the other computer can receive it, but i dont know how to tell that first computer that the second one received it, so they can both move on, unless a UDPsend will return an error until the other computer does the UDPrecv command, in which case it'll work perfectly.... time for some testing :graduated:

edit: so i was looking, looks like the TCP commands will work for what i've got in mind (with some creative tinkering :() thanks for help though.

Here is what I'm gonna do. Have a script setup so that 1 computer, once it reaches the sycn spot, activates tcp and tcplisten, while having previously set a variable to -1 (which is the error code), and have the second computer do the same thing except with tcpconnect instead of tcplisten, with the same error code, and have it wait about 15-30 seconds after stopping, and to continue looping and attempting connection. Once the connection is established, both computer's will return a socket identifier instead of the error code, which will trigger the end of the loop and loop the entire script again.

Edited by Kuram

Share this post


Link to post
Share on other sites

if both computers have time synced with windows time it should be accurate within 200ms...

udpopen is out of my depth of knowledge....

good luck maybe an expert can post here and help you...

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