Ping with c$socket

Hello,

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

 

Greetings
David

Parents
  • 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.
Reply
  • 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.
Children
No Data