Ping with c$socket

Hello,

ist it possible to make a ping with the c$socket library?

 

Greetings
David

Parents
  • ok, i decided to test the PingStatus Class from WMI. But i have some problems to translate this VB code to cobol.

               

    VB:

    objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

    objWMIService = objSWbemLocator.ConnectServer(source)

                                    Dim resultset = objWMIService.Get("Win32_PingStatus.Address='" & target & "'")

                                    If Not IsDBNull(resultset.StatusCode) Then

                                        If resultset.StatusCode = 0 Then

                                            responsePA = resultset.ProtocolAddress

                                            responseRT = resultset.ResponseTime

    Cobol:

          ***********************************************************
           create-wmi-locator section.
               create @SWbemLocator of @WbemScripting
                      handle in wmi-locator.

               modify wmi-locator @ConnectServer(
                                by name strServer    "localhost"    | Change to make ping from Other computer
                                by name strNamespace "root\CIMV2"
          *                      by name strUser      " "          | if use other computer
          *                      by name strPassword  " "          | if use other computer
                                )
                      returning wmi-service.

           create-wmi-locator-ende.
               exit.
           create-wmi-locator-e.
          ***********************************************************
           create-wmi-ping section.
               initialize wmi-objpath.

               string "Win32_PingStatus.Address='"
                      "10.21.55.201"
                      "'"
                      delimited by size into wmi-objpath.

               modify wmi-service @Get(
                                by name strObjectPath wmi-objpath
                                )
                      returning wmi-object.

               stop "test".

               inquire wmi-object
                 @Properties::@Item("StatusCode")::@Value      in p-status
                 @Properties::@Item("ProtocolAddress")::@Value in p-pAddress
                 @Properties::@Item("ResponseTime")::@Value    in p-rTime.


           create-wmi-ping-ende.
               exit.
           create-wmi-ping-e.
          ***********************************************************
           single-ping section.
               perform create-wmi-locator.
               perform create-wmi-ping.

               display message box p-status
                       newline     p-pAddress
                       newline     p-rTime.

               destroy wmi-object.
               destroy wmi-service.
               destroy wmi-locator.

           single-ping-ende.
               exit.
           single-ping-e.
          ***********************************************************

    The Part i marked red, the problem occurs.

    I create the Locator, connect to the wmi-service.

    I call the ping class with the address to ping.

    The problem i have is, how do i inquire the single values from the responce.

    I get a System Exception with Member not found.


    Has here anyone experience?
    I am not sure if i need to inquire the properties... i try to follow with the ActiveX DEF Utility to get correct Property.

Reply
  • ok, i decided to test the PingStatus Class from WMI. But i have some problems to translate this VB code to cobol.

               

    VB:

    objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

    objWMIService = objSWbemLocator.ConnectServer(source)

                                    Dim resultset = objWMIService.Get("Win32_PingStatus.Address='" & target & "'")

                                    If Not IsDBNull(resultset.StatusCode) Then

                                        If resultset.StatusCode = 0 Then

                                            responsePA = resultset.ProtocolAddress

                                            responseRT = resultset.ResponseTime

    Cobol:

          ***********************************************************
           create-wmi-locator section.
               create @SWbemLocator of @WbemScripting
                      handle in wmi-locator.

               modify wmi-locator @ConnectServer(
                                by name strServer    "localhost"    | Change to make ping from Other computer
                                by name strNamespace "root\CIMV2"
          *                      by name strUser      " "          | if use other computer
          *                      by name strPassword  " "          | if use other computer
                                )
                      returning wmi-service.

           create-wmi-locator-ende.
               exit.
           create-wmi-locator-e.
          ***********************************************************
           create-wmi-ping section.
               initialize wmi-objpath.

               string "Win32_PingStatus.Address='"
                      "10.21.55.201"
                      "'"
                      delimited by size into wmi-objpath.

               modify wmi-service @Get(
                                by name strObjectPath wmi-objpath
                                )
                      returning wmi-object.

               stop "test".

               inquire wmi-object
                 @Properties::@Item("StatusCode")::@Value      in p-status
                 @Properties::@Item("ProtocolAddress")::@Value in p-pAddress
                 @Properties::@Item("ResponseTime")::@Value    in p-rTime.


           create-wmi-ping-ende.
               exit.
           create-wmi-ping-e.
          ***********************************************************
           single-ping section.
               perform create-wmi-locator.
               perform create-wmi-ping.

               display message box p-status
                       newline     p-pAddress
                       newline     p-rTime.

               destroy wmi-object.
               destroy wmi-service.
               destroy wmi-locator.

           single-ping-ende.
               exit.
           single-ping-e.
          ***********************************************************

    The Part i marked red, the problem occurs.

    I create the Locator, connect to the wmi-service.

    I call the ping class with the address to ping.

    The problem i have is, how do i inquire the single values from the responce.

    I get a System Exception with Member not found.


    Has here anyone experience?
    I am not sure if i need to inquire the properties... i try to follow with the ActiveX DEF Utility to get correct Property.

Children
No Data