TIP: Click on subject to list as thread! ANSI
echo: os2inet
to: JON PARISE
from: LAWRENCE LUCIER
date: 1997-08-21 22:52:00
subject: Re: Ping

Jon Parise @ 1:2606/421 wrote on 08-20-97 23:17 about *Re: Ping*
 JP>        Yes, but I'm looking for the actual format of the ping
 JP> with some source code.  I'm interested in writing my own version. 
 Taken from the IBM TCP/IP Warp programming interface:
 The ping() call sends a ping to the remote host to determine if the host is 
responding. 
 Syntax 
 
 
 #include 
 
 int ping(addr, len)
 unsigned long addr;
 int len;
 
 Parameters 
  addr 
    Internet address of the host in network byte order 
  len 
    Length of the ping packets 
  
  Description 
  The ping() call sends a ping to the host with ICMP Echo Request.  The 
ping() call is useful to determine whether the 
  host is alive before attempting FTP transfers, because time-out on regular 
connections is more than a minute.  The 
  ping() call returns within 3 seconds, at most, if the host is not 
responding. 
  Return Values 
  If the return value is positive, the return value is the number of 
milliseconds it took for the echo to return.  If the 
  return value is negative, it contains an error code. 
  The following are ping() call return codes and their corresponding 
descriptions: 
  Return Code       Description 
  PINGREPLY         Host does not reply 
  PINGSOCKET        Unable to obtain socket 
  PINGPROTO         Unknown protocol ICMP 
  PINGSEND          Send failed 
  PINGRECV          Recv() failed 
  
  Examples 
  #include 
  #include 
  #include 
  
  struct hostent *hp;     /* Pointer to host info */
  
  main(int argc, char *argv[], char *envp[])
  {
     int i;
     unsigned long addr;
  
     if (argc!=2) {
         printf("Usage: p \n");
         exit(1);
     }
  
     hp = gethostbyname(argv[1]);
  
  
  if (hp) {
          memcpy( (char *)&addr, hp->h_addr, hp->h_length);
          i = ping(addr,256);
          printf("ping reply in %d milliseconds\n",i);
  } else {
             printf("unknown host\n");
             exit(2);
     }
     ftplogoff(); /* close all connections */
  }
  
Hope this helps and sorry about not noticing the "source" reference in your 
original message.............:-)
--- Sqed/32 1.13b2/r15155
---------------
* Origin: T-Shirts 'N Genes BBS - (250) 748-3408 v32b v42b XA CM (1:340/204)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.