• Obtain Socket object from within script

    From Mortifis@VERT/ALLEYCAT to All on Tue Aug 13 10:29:37 2019
    What is the best way to create a socket object on an already connected client?

    I have a sample door that already has user.* object access but I want to create a new hot socket connection based on the current users client.socket; client.port; client.protocol so that I can then:

    var s = new Socket(SOCK_STREAM, user.protocol);
    then var real_ip = s.remote_ip_address; ... type thingie

    Is this possible?


    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    ■ Synchronet ■ AlleyCat! BBS - http://alleycat.synchro.net:81
  • From echicken@VERT/ECBBS to Mortifis on Tue Aug 13 10:45:41 2019
    Re: Obtain Socket object from within script
    By: Mortifis to All on Tue Aug 13 2019 10:29:37

    I have a sample door that already has user.* object access but I want to create a new hot socket connection based on the current users client.socket; client.port; client.protocol so that I can then:

    Why not just use client.socket?

    var s = new Socket(SOCK_STREAM, user.protocol);
    then var real_ip = s.remote_ip_address; ... type thingie

    The value of client.socket.remote_ip_address is already available to you.

    Apart from maybe reading this value, I have very rarely ever needed to interact directly with the client
    socket in the context of a JS "door". IO with the client should really go through the existing
    console/bbs methods unless there's a really good reason to bypass them.

    I suspect this isn't a path you need to go down.

    Is this possible?

    I think you can do:

    var s = new Socket(true, client.socket.descriptor);

    As you can guess, I doubt if this is necessary in your case.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Tue Aug 13 12:56:54 2019
    Re: Obtain Socket object from within script
    By: Mortifis to All on Tue Aug 13 2019 10:29:37

    I have a sample door that already has user.* object access but I want to create a new hot socket connection based on the current users client.socket; client.port; client.protocol so that I can then:

    Why not just use client.socket?

    var s = new Socket(SOCK_STREAM, user.protocol);
    then var real_ip = s.remote_ip_address; ... type thingie

    The value of client.socket.remote_ip_address is already available to you.

    Apart from maybe reading this value, I have very rarely ever needed to interact directly with the client
    socket in the context of a JS "door". IO with the client should really go through the existing
    console/bbs methods unless there's a really good reason to bypass them.

    I suspect this isn't a path you need to go down.

    Is this possible?

    I think you can do:

    var s = new Socket(true, client.socket.descriptor);

    As you can guess, I doubt if this is necessary in your case.

    You're right, not likely necessary. I had tried client.socket.remote_ip_address but it was still showing as 127.0.0.1, so I suspect that connecting to an already open socket as var s = new Socket(true, client.socket.descriptor); print(s.Socket.remote_ip_address) would likely just show what was already stored in client.socket.remote_ip_address; which is already user.ip_address and bbs.atcode["CID] anyway ... hmmm...

    Thanks, EC, I appreciate the response





    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    ■ Synchronet ■ AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Mortifis@VERT/ALLEYCAT to echicken on Tue Aug 13 13:11:46 2019
    You're right, not likely necessary. I had tried client.socket.remote_ip_address but it was still showing as 127.0.0.1, so I suspect that connecting to an already open socket as var s = new Socket(true, client.socket.descriptor); print(s.Socket.remote_ip_address) would likely just show what was already stored in client.socket.remote_ip_address; which is already user.ip_address and bbs.atcode["CID] anyway ... hmmm...

    despite the error in the print statement (should be s.remote_ip_address) the assumption was correct ... that value is still 127.0.0.1 and not 24.138.28.115 :-/


    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    ■ Synchronet ■ AlleyCat! BBS - http://alleycat.synchro.net:81