Skip to main content
bduffy323
Inspiring
February 8, 2013
Question

Socket POST connection close

  • February 8, 2013
  • 1 reply
  • 1160 views

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!

This topic has been closed for replies.

1 reply

Kris1979
Participant
November 13, 2017

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);