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

Socket POST connection close

Explorer ,
Feb 08, 2013 Feb 08, 2013

Copy link to clipboard

Copied

Hello all,

I was wondering if there was a way to close a connection once the server writes back to the connection? I have this post:

var conn = new Socket;

//conn.timeout = 300;

//conn.timeout = 10;

conn.timeout = 2;

var tempzzz = $.hiresTimer;

conn.open(vHost);

conn.write("POST " +vSubDir+"/update.asp HTTP/1.1\r\n");

conn.write("Host: " + vHost + "\r\n");

conn.write("Content-Length: " + data_string.length + "\r\n");

conn.write("Content-Type: application/x-www-form-urlencoded\r\n");

conn.write("\r\n");

conn.write(data_string);

var reply = "";

reply = conn.read(999999);

conn.close();

var myTime = $.hiresTimer/1000000;

alert("found reply "+myTime)

When I run this code with the timeout set to 2 my alert states found the reply in 1.75 sec.

When I run this code with the timeout set to 10 my alert states found the reply in 9.87 sec.

When I run this code with the timeout set to 300 my alert states found the reply in 126.23 sec.

Any idea how to close the connection and therefore make indesign active again the moment a server replies? I cannot use a get because I am sending a lot of data to the server which would exceed the URL size limit. Any information would be helpful, thanks!

TOPICS
Scripting

Views

1.1K

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
New Here ,
Nov 13, 2017 Nov 13, 2017

Copy link to clipboard

Copied

LATEST

Well.... Seems quite post apocalyptic in here, but here's my reply for those interested:

conn.open(vHost); 

conn.write("POST " +vSubDir+" HTTP/1.1\r\n"); 

conn.write("Host: " + vHost + "\r\n"); 

conn.write("Content-Length: " + data_string.length + "\r\n"); 

conn.write("Content-Type: application/x-www-form-urlencoded\r\n");

//Try this one:

conn.write("Connection: close\r\n");

conn.write("\r\n");

conn.write(data_string); 

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