how to send and receive data in realtime Topic is solved
how to send and receive data in realtime
hey guys, I'm trying to make a script that when pressing F5 on a machine, another machine also presses F5 (with the least possible delay, this is important).
what would be the best way to send/receive data between these machines?
the data content doesn't matter, I just need the send/receive data to trigger the script
what would be the best way to send/receive data between these machines?
the data content doesn't matter, I just need the send/receive data to trigger the script
Re: how to send and receive data in realtime
Are they on the same network with a shared drive?
Re: how to send and receive data in realtime
I was going to suggest writing to and reading from a shared drive, which I've done on my own network in real time and it worked pretty well, but there's more involved if you're saying you want to communicate through the internet. I'll leave that to others.
Re: how to send and receive data in realtime Topic is solved
if least possible delay is important to you, It is recommended to use TCP sockets.
viewtopic.php?t=35120
Using SocketTCP class for different networks
viewtopic.php?t=35120
Using SocketTCP class for different networks
Re: how to send and receive data in realtime
I managed to send a text as follows:neovis wrote: ↑06 Jul 2022, 20:39if least possible delay is important to you, It is recommended to use TCP sockets.
viewtopic.php?t=35120
Using SocketTCP class for different networks
1- I opened port 8000 on my router
2- I opened port 8000 on my Windows10 computer's firewall (inbound and outbound)
however I had a problem, after a few seconds sending texts via socket the connection error script.
when i restart the script it works for a few more seconds and the connection error again.
I couldn't diagnose the problem, the script is working as follows:
Server Script:
Code: Select all
#NoEnv
SetBatchLines, -1
#Include ..\Socket.ahk
global DC_SERV := True
global DC_CLI := False
Server := new SocketTCP()
Server.OnAccept := Func("OnAccept")
Server.Bind(["0.0.0.0", 8000])
Server.Listen()
OnAccept(Server) {
GLOBAL
Sock := Server.Accept()
ToolTip, % Sock.RecvText()
if (DC_SERV)
Sock.Disconnect()
}
Client Script:
Code: Select all
#NoEnv
SetBatchLines, -1
#Include ..\Socket.ahk
global DC_SERV := True
global DC_CLI := False
Loop
{
x := new SocketTCP()
x.Connect(["187.46.742.551", 8000]) ;187.46.742.551 = my global IP
x.SendText(A_Index)
Sleep, 10
if (DC_CLI)
x.Disconnect()
}
return
Re: how to send and receive data in realtime
There is no need to put the create a socket in a loop.Client Script:Code: Select all
#NoEnv SetBatchLines, -1 #Include ..\Socket.ahk global DC_SERV := True global DC_CLI := False Loop { x := new SocketTCP() x.Connect(["187.46.742.551", 8000]) ;187.46.742.551 = my global IP x.SendText(A_Index) Sleep, 10 if (DC_CLI) x.Disconnect() } return
Try to like this:
Code: Select all
x := new SocketTCP()
x.Connect(["187.46.742.551", 8000]) ;187.46.742.551 = my global IP
Loop
{
x.SendText(A_Index)
Sleep, 10
if (DC_CLI)
x.Disconnect()
}
Re: how to send and receive data in realtime
neovis wrote: ↑06 Jul 2022, 23:33
There is no need to put the create a socket in a loop.
Try to like this:Code: Select all
x := new SocketTCP() x.Connect(["187.46.742.551", 8000]) ;187.46.742.551 = my global IP Loop { x.SendText(A_Index) Sleep, 10 if (DC_CLI) x.Disconnect() }
ERROR
Re: how to send and receive data in realtime
It seems that the connection is disconnected and the transmission is not possible. Dont disconnect from the server side.
Please remove the code below on the server side.
Code: Select all
if (DC_SERV)
Sock.Disconnect()
Re: how to send and receive data in realtime
@ibieel - you can simply provide AHK's error messages using copy and paste Ctrl+C them. No embedded image necessary. JFTR & HTH