ist it possible to make a ping with the c$socket library?
Greetings David
I believe C$SOCKET only provides TCP sockets. The TCP/IP ping protocol is actually implemented with ICMP, not TCP.
However, if you simply want to test whether a machine is responding, you can use the return status of a connection attempt as a heuristic. Try to connect a client socket to some port on the target. If that succeeds, simply close the client socket; you know the machine is responding. If it fails, get the error code. ECONNRESET usually indicates the target is available. ENETUNREACH, EHOSTUNREACH, ETIMEDOUT, etc generally indicate the target machine is not available, either because it's not up or due to network failure.
ist it possible to make a ping with the c$socket library?
Greetings David
ok, thanks for the info. I see that with the ICMP but was not sure if there is a way with c$socket.
I also tried to get the System.Net.NetworkInformation.Ping Class with NetDefGen, but i don't fint that class there.
I will look for another way to get a ping solution with cobol.
ist it possible to make a ping with the c$socket library?
Greetings David
I want to realize a multi-ping and i don't think that c$system is a real solution for it.
I check at moment the ActiveX @WbemScripting to use from WMI the Win32_PingStatus Class.
But seems this is also not fast enough. But at moment the best Solution i see.
the icmp.dll is also not a real solution, cause Microsoft don't support it in all systems anymore.
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.
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.
ist it possible to make a ping with the c$socket library?
Greetings David
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.
*** 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.