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

Socket Connect Fail

Community Beginner ,
Oct 13, 2019 Oct 13, 2019

Hi everyone, here is some problem I got in last few days:

I build a Socket Server (an .exe file, with C#) on a machine, Internet IP address, and PORT is also open in this machine;

I can connect to that server with C# and Windows Command line "telnet <IP> <PORT>".

but I can't connect to this server with ExtendScript Socket Object, socket error is: "cannot connect to <IP>:<PORT>".

 

And thanks for your replies..

 

Here is my ExtendScript code:

function connectToServer() {
    var tcp = new Socket();
    tcp.encoding = 'UTF-8';
    try {
        var a = tcp.open(SERVER_IP + ':' + SERVER_PORT, 'UTF-8');
        if (!a) {
            alertError('connect failed');
            return null;
        }
            
        tcp.writeln('this is a connect test');
        return tcp.read(99999999);
    } catch (e) {
        alertError(e);
    } finally {
        tcp.close();
    }
    return null;
}

PS.

function alertError(msg) {
    alert(msg,
        ALERT_NAME,
        true
    );
}

 

TOPICS
Error or problem , Scripting
964
Translate
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
Participant ,
Oct 15, 2019 Oct 15, 2019

Have you checked the "Allow scripts to write files and access the network" box in Edit>Preferences>Scripts and Expressions?

Translate
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
Enthusiast ,
Nov 01, 2019 Nov 01, 2019
LATEST

If you are using SSL, the sockets will not work with ExtendScript.

Translate
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