Ping with c$socket

Hello,

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

 

Greetings
David

Parents
  • ok, i found it. In cobol it is a bit more complicated i think then in VB

          ***********************************************************
           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.
               initialize p-status.
               initialize p-statusT.
               initialize p-pAddress.
               initialize p-rAddress.
               initialize p-rTime.

          ***  Set Ping command
               string "Win32_PingStatus.Address='"
                      "10.21.51.253'"
                      ",ResolveAddressNames=True" | for inquire Hostname (slower)
                      delimited by size into wmi-objpath.

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

          ***  Inquire PropertySet
               inquire wmi-object  @Properties in wmi-propSet.

          ***  Get Status
               modify  wmi-propSet @Item(
                                by name strName "StatusCode"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-status.
               destroy wmi-prob.

               evaluate p-status
                  when     0
                       move "Success"                          to p-statusT
                  when 11001
                       move "Buffer Too Small"                 to p-statusT
                  when 11002
                       move "Destination Net Unreachable"      to p-statusT
                  when 11003
                       move "Destination Host Unreachable"     to p-statusT
                  when 11004
                       move "Destination Protocol Unreachable" to p-statusT
                  when 11005
                       move "Destination Port Unreachable"     to p-statusT
                  when 11006
                       move "No Resources"                     to p-statusT
                  when 11007
                       move "Bad Option"                       to p-statusT
                  when 11008
                       move "Hardware Error"                   to p-statusT
                  when 11009
                       move "Packet Too Big"                   to p-statusT
                  when 11010
                       move "Request Timed Out"                to p-statusT
                  when 11011
                       move "Bad Request"                      to p-statusT
                  when 11012
                       move "Bad Route"                        to p-statusT
                  when 11013
                       move "TimeToLive Expired Transit"       to p-statusT
                  when 11014
                       move "TimeToLive Expired Reassembly"    to p-statusT
                  when 11015
                       move "Parameter Problem"                to p-statusT
                  when 11016
                       move "Source Quench"                    to p-statusT
                  when 11017
                       move "Option Too Big"                   to p-statusT
                  when 11018
                       move "Bad Destination"                  to p-statusT
                  when 11032
                       move "Negotiating IPSEC"                to p-statusT
                  when 11050
                       move "General Failure"                  to p-statusT
                  when other
                       move "Unknow"                           to p-statusT
               end-evaluate.

               if p-status not = zeroes go to create-wmi-ping-ende.

          ***  Get ProtocolAddress
               modify  wmi-propSet @Item(
                                by name strName "ProtocolAddress"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-pAddress.
               destroy wmi-prob.

          ***  Get ProtocolAddressResolved
               modify  wmi-propSet @Item(
                                by name strName "ProtocolAddressResolved"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-rAddress.
               destroy wmi-prob.

          ***  Get ResponseTime
               modify  wmi-propSet @Item(
                                by name strName "ResponseTime"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-rTime.
               destroy wmi-prob.

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

               display message box "Status Code: " p-status
                       newline     "Status Text: " p-statusT
                       newline     "Address: "     p-pAddress
                       newline     "RespAddress: " p-rAddress
                       newline     "RespTime:    " p-rTime.

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

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

     


     

Reply
  • ok, i found it. In cobol it is a bit more complicated i think then in VB

          ***********************************************************
           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.
               initialize p-status.
               initialize p-statusT.
               initialize p-pAddress.
               initialize p-rAddress.
               initialize p-rTime.

          ***  Set Ping command
               string "Win32_PingStatus.Address='"
                      "10.21.51.253'"
                      ",ResolveAddressNames=True" | for inquire Hostname (slower)
                      delimited by size into wmi-objpath.

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

          ***  Inquire PropertySet
               inquire wmi-object  @Properties in wmi-propSet.

          ***  Get Status
               modify  wmi-propSet @Item(
                                by name strName "StatusCode"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-status.
               destroy wmi-prob.

               evaluate p-status
                  when     0
                       move "Success"                          to p-statusT
                  when 11001
                       move "Buffer Too Small"                 to p-statusT
                  when 11002
                       move "Destination Net Unreachable"      to p-statusT
                  when 11003
                       move "Destination Host Unreachable"     to p-statusT
                  when 11004
                       move "Destination Protocol Unreachable" to p-statusT
                  when 11005
                       move "Destination Port Unreachable"     to p-statusT
                  when 11006
                       move "No Resources"                     to p-statusT
                  when 11007
                       move "Bad Option"                       to p-statusT
                  when 11008
                       move "Hardware Error"                   to p-statusT
                  when 11009
                       move "Packet Too Big"                   to p-statusT
                  when 11010
                       move "Request Timed Out"                to p-statusT
                  when 11011
                       move "Bad Request"                      to p-statusT
                  when 11012
                       move "Bad Route"                        to p-statusT
                  when 11013
                       move "TimeToLive Expired Transit"       to p-statusT
                  when 11014
                       move "TimeToLive Expired Reassembly"    to p-statusT
                  when 11015
                       move "Parameter Problem"                to p-statusT
                  when 11016
                       move "Source Quench"                    to p-statusT
                  when 11017
                       move "Option Too Big"                   to p-statusT
                  when 11018
                       move "Bad Destination"                  to p-statusT
                  when 11032
                       move "Negotiating IPSEC"                to p-statusT
                  when 11050
                       move "General Failure"                  to p-statusT
                  when other
                       move "Unknow"                           to p-statusT
               end-evaluate.

               if p-status not = zeroes go to create-wmi-ping-ende.

          ***  Get ProtocolAddress
               modify  wmi-propSet @Item(
                                by name strName "ProtocolAddress"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-pAddress.
               destroy wmi-prob.

          ***  Get ProtocolAddressResolved
               modify  wmi-propSet @Item(
                                by name strName "ProtocolAddressResolved"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-rAddress.
               destroy wmi-prob.

          ***  Get ResponseTime
               modify  wmi-propSet @Item(
                                by name strName "ResponseTime"
                                )
                       returning wmi-prob.
               inquire wmi-prob    @Value in p-rTime.
               destroy wmi-prob.

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

               display message box "Status Code: " p-status
                       newline     "Status Text: " p-statusT
                       newline     "Address: "     p-pAddress
                       newline     "RespAddress: " p-rAddress
                       newline     "RespTime:    " p-rTime.

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

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

     


     

Children
No Data