Hello,
I'm using a Socket to connect to a local site. In most cases the connection is established good, but in some cases the Socket somehow "hangs", so does the Photoshop and it must be Force-quited.
Are there any solutions to prevent this from happening? I prefer the script to quits before/without the task is complete, instead of "hanged" Photoshop.
Thanks in advance!
Code: Select alltry{
var conn = new Socket();
conn.encoding = "BINARY";
conn.open(domain + ":" + port);
conn.timeout=2;
bar.progress.value++;
// post
conn.writeln("POST /"+myUploader+" HTTP/1.1");
conn.writeln("Host: "+myHost);
conn.writeln("Keep-Alive: 300");
conn.writeln("Connection: keep-alive");
conn.writeln("Content-Length: "+contentLength);
conn.writeln("Expect: 100-continue");
conn.writeln("Content-Type: multipart/form-data; boundary=1234");
conn.writeln("");
bar.progress.value++;
compteurFile += conn.writeln("--1234");
compteurFile += conn.writeln('Content-Disposition:form-data; name="test_file"; filename="'+filename+'"');
compteurFile += conn.writeln("Content-Type: "+typeFile);
compteurFile += conn.writeln("");
bar.progress.value++;
mystring = conn.readln();
if (mystring == "HTTP/1.1 100 Continue") {
if (fileTarget.open("r")) {
var prefs ={};// Creates the Object
prefs.username = username;
prefs.password = password;
var desc1 = new ActionDescriptor();
desc1.putString(0,prefs.toSource());
try{
app.putCustomOptions( 'e5a236e0-f7dd-11de-8a39-0800200c9a66', desc1 );
}catch(e){
}; // End of Try Catch};
myLine = fileTarget.read();
compteurFile+=conn.write(myLine);
bar.progress.value++;
fileTarget.close();
}
}
compteurFile += conn.writeln("");
compteurFile += conn.write("--1234--");
// close
var reply = '';
while(!conn.eof) {
reply = conn.readln();
bar.progress.value++;
};
alert(removeHeaders(reply));
conn.close();
}
catch(e){
alert(e);
}
This is the code I'm using...
[SOLVED]Photoshop CS5 hangs on Socket operations?
-
Svrnc_Tprunkov
[SOLVED]Photoshop CS5 hangs on Socket operations?
I've found out that conn.readln is creating the hanging...
Perhaps one should consider if reading response from server is worth the risk of Photoshop crashing... When I remove this
Code: Select all while(!conn.eof) {
reply = conn.readln();
bar.progress.value++;
};
the hanging stopped and the speed of completing the script increased significantly.
Perhaps one should consider if reading response from server is worth the risk of Photoshop crashing... When I remove this
Code: Select all while(!conn.eof) {
reply = conn.readln();
bar.progress.value++;
};
the hanging stopped and the speed of completing the script increased significantly.