1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Openedge use Windows service name to connect to port

Discussão em 'StackOverflow' iniciado por fdantas, Janeiro 2, 2019.

  1. fdantas

    fdantas Administrator Moderador

    I'm trying to write a program that will test a Linux port to see if it's listening. The program runs on a Windows box and the port number could be variable, depending on the service selected. I'm need to look up the port number using the Windows Service file. Below is my procedure:

    define input parameter ip-network-id as char no-undo.
    DEFINE VARIABLE hSocket AS HANDLE NO-UNDO.
    DEFINE VARIABLE cService AS CHARACTER NO-UNDO.
    DEFINE VARIABLE cHostName AS CHARACTER NO-UNDO.
    DEFINE VARIABLE lResult AS LOGICAL NO-UNDO.

    CREATE SOCKET hSocket.

    GET-KEY-VALUE SECTION "DATABASE" KEY "dbhostname" VALUE cHostName.

    ASSIGN
    cService = "txipd" + ip-network-id /*ip-network-id = "fis" */
    lResult = hSocket:CONNECT("-H " + cHostName + " -S " + cService) NO-ERROR.

    IF lResult THEN do:
    MESSAGE cHostName "is accepting Cilent/Server connections on" cService " ."
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

    /* Once done with the database disconnect and delete the object */
    hSocket:DISCONNECT() NO-ERROR.
    DELETE OBJECT hSocket NO-ERROR.
    end.
    Else
    MESSAGE "The Database is not listening on this port" cService lResult cHostName
    VIEW-AS ALERT-BOX INFO BUTTONS OK.


    My Windows Services file contains the follow entry:

    txipdfis 31357/tcp


    ip-network-id could equal one of many options selected from a browse, the service txipdfis might be on a different port number depending on how the particular installation was setup so I need to look for "txipdfis" in the Windows service file to determine the correct port number. Is this possible?

    Continue reading...

Compartilhe esta Página