Ping with c$socket

Hello,

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

 

Greetings
David

Parents
  • I used C# to create a simple .Net module to ping an address.

    Here my code:

    C#

    using log4net;
    using log4net.Config;
    using System;
    using System.IO;
    using System.Reflection;
    using System.Net.NetworkInformation;

    namespace WGPing.Client
    {
    public class WGClient
    {

    private ILog _log { get; set; }

    public WGClient()
    {

    this.createLog();

    }

    //Return a bool true if I ping the address
    public bool PingHost(String nameOrAddress)
    {
    bool pingable = false;
    Ping pinger = new Ping();
    try
    {
    if (nameOrAddress != "0.0.0.0")
    {
    PingReply reply = pinger.Send(nameOrAddress);
    if (reply != null) pingable = reply.Status == IPStatus.Success;
    }
    }
    catch (PingException x)
    {
    _log.Error("Errore PingHost " x.Message);
    }
    return pingable;
    }


    }
    }

    Cobol:

    ...
    77 WGPing-Returnpic9(01) comp-x.
    ...
    modify WgPing-Handle,
    "@PingHost"(w-address)
    giving WGPing-return.
     
Reply
  • I used C# to create a simple .Net module to ping an address.

    Here my code:

    C#

    using log4net;
    using log4net.Config;
    using System;
    using System.IO;
    using System.Reflection;
    using System.Net.NetworkInformation;

    namespace WGPing.Client
    {
    public class WGClient
    {

    private ILog _log { get; set; }

    public WGClient()
    {

    this.createLog();

    }

    //Return a bool true if I ping the address
    public bool PingHost(String nameOrAddress)
    {
    bool pingable = false;
    Ping pinger = new Ping();
    try
    {
    if (nameOrAddress != "0.0.0.0")
    {
    PingReply reply = pinger.Send(nameOrAddress);
    if (reply != null) pingable = reply.Status == IPStatus.Success;
    }
    }
    catch (PingException x)
    {
    _log.Error("Errore PingHost " x.Message);
    }
    return pingable;
    }


    }
    }

    Cobol:

    ...
    77 WGPing-Returnpic9(01) comp-x.
    ...
    modify WgPing-Handle,
    "@PingHost"(w-address)
    giving WGPing-return.
     
Children
No Data