Forum breadcrumbs - You are here:Aaronia SPECTRAN V6 Real Time Spectrum Analyzer Series Support ForumSPECTRAN V6 SDK / API / Remote Control: JavaScript Support | Script Block (RTSA-Suite PRO)stable TCP server in script block
stable TCP server in script block
#1 · 20/09/2023, 07:40
Quote from Ronald on 20/09/2023, 07:40I've implement a TCP server on script block for having a connection out of RTSA. my code for this is as follows:
///////////////////////////////////////////////////////
import {TCP,TCPServer} from "tcp.js"import {Async} from "async.js"var host = "localhost"var port = 1001;TCPServer.listen(null,port,(err_socket,socket) => {if(err_socket)console.log("socket error")else{Async.forever(cb => {socket.accept((err_client,client)=>{if(err_client)console.log("accept error")else{console.log("Client Connected!")client.receive().then((buffer)=>{console.log(UTF8.decode(buffer))client.send(UTF8.encode("Hello Client!"),(err_send)=>{if(err_send)console.log("send error")})})}})})}})/////////////////////////////////////////////////It is written by the aid of your JavaScript documentation. and it simply works when I run the script and run my client out of the RTSA for one time!So I think the problem is that the server is not always listening and it just run one time.could you please help me to solve the problem?
I've implement a TCP server on script block for having a connection out of RTSA. my code for this is as follows:
///////////////////////////////////////////////////////
import {TCP,TCPServer} from "tcp.js"
import {Async} from "async.js"
var host = "localhost"
var port = 1001;
TCPServer.listen(null,port,(err_socket,socket) => {
if(err_socket)
console.log("socket error")
else{
Async.forever(cb => {
socket.accept((err_client,client)=>{
if(err_client)
console.log("accept error")
else{
console.log("Client Connected!")
client.receive().then((buffer)=>{
console.log(UTF8.decode(buffer))
client.send(UTF8.encode("Hello Client!"),(err_send)=>{
if(err_send)
console.log("send error")
})})}})})}})
/////////////////////////////////////////////////
It is written by the aid of your JavaScript documentation. and it simply works when I run the script and run my client out of the RTSA for one time!
So I think the problem is that the server is not always listening and it just run one time.
could you please help me to solve the problem?
Click for thumbs down.0Click for thumbs up.0
Last edited on 20/09/2023, 07:40 by Ronald