• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Socket - xml back to server

Community Beginner ,
Sep 05, 2016 Sep 05, 2016

Copy link to clipboard

Copied

I have a long script running (on InDesign) that I would like to keep track of running on another PC in our network.

I've created a simple Jquery/Boostrap web interface that reads in a XML file every few minutes. So what I am looking doing is have this long running script create a XML file, which the web interface will display.

The issue I am having is constructing the XML to post back to the server. I can read a file fine.

var website = "mySillytest.com:80";

var path = "/thingy/newXMLDocument.xml";

reply = "";

conn = new Socket;

if (conn.open (website)) {

    conn.write ("GET "+path+" HTTP/1.0\n\n");   

    reply = conn.read(999999);

    conn.close();

}else{

    $.writeln ("NO CONNECTION");

    }

$.writeln(reply);

I'm just overwriting the same file newXMLDocument.xml all the time at the same location this one is been read from.

I have to use "POST" in conn.write, but I'm unsure how to proceed from there.

Any pointers would be welcome.

TOPICS
Scripting

Views

241

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 06, 2016 Sep 06, 2016

Copy link to clipboard

Copied

If it's on a same network why not simply write the file to a shared volume ?

var log = function(data) {

  var f = File ( "/shared/volume/directory/log.xml" );

  f.encoding = "UTF-8";

  f.open('a');

  f.writeln ( data.toXMLString() );

  f.close();

}

var data = <data date="xxx" message="sdkljlqdjslk"/>

log ( data );

FWIW

Loic

Ozalto | Productivity Oriented - Loïc Aigon

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 06, 2016 Sep 06, 2016

Copy link to clipboard

Copied

LATEST

the .write() method's parameter is a string. So you can either construct the xml in memory and pass it to the write method (conn.write(theXml.toXMLString()) or,if you have the xml in a file, you need to open that file, read it's contents (close it) and pass the content to the connection.

However, Loic is right. If you can use a file, don't bother with the socket.

Or, if you want to use the socket, then your web app should not try to look for a file, but just accept incoming connections from indesign.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines