Richard Bos a écrit :
jacob navia <ja***@jacob.remcomp.frwrote:
>>TK******@gmail.com a écrit :
>>>I dont need to write whole ping function - just need a return
value :).
>>If you are using the lcc-win32 compiler system you can do:
#include <ping.h>
This is a joke, right? You don't _really_ have a header all for
ping-like functionality, which probably consists of a single function
even with you?
Richard
It is a matter of design. Yes, there is a header for just the
ping function. The reason is that the interface is quite complicated.
typedef struct __Ping {
/* -------------input section -------------------------------------*/
char *HostName;/* Host name/Ip address of destination. Required */
int TotalPackets;/*OPTIONAL: Nb of packets to send before exiting.
Default is 5 packets */
int DataSize;/*OPTIONAL: Data size in the sent packets. Default: 32*/
int SleepTime;/* OPTIONAL: Time (in ms) to wait after each packet.
Default is 1000 ms. */
int MaxTimeouts;/*OPTIONAL: Nb. of Timeouts allowed.
*/
int (*Callback)(struct __Ping *);/* OPTIONAL: Callback function at
each packet received and at each timeout. */
int ttl;/* OPTIONAL: Time to live. Default is 128 */
int verbose;/* Optional: Whether to print messages to stdout or not.*/
/* -------------output section -----------------------------------*/
int TotalReceived; // OUT: Total packets received
int TotalSent; // OUT: Total packets sent
int MaxTime; // OUT: Maximum time (ms)
int MinTime; // OUT: Minimum time (ms)
int TotalTime; // OUT: Total time used
int Timeouts; // OUT: Number of timeouts
int Errorcode;/*WSAGetLastError() report when an error occurs, or
a negative number, specific to the ping function. */
int ShortPackets; /* OUT: Packets that weren't sent completely due to
errors */
char ip[MAXIPNAME];/* OUT: IP of destination (Can be the same as
HostName) */
/* ---------------- Per packet specific data ----------------------*/
int Bytes; // OUT: Bytes received
int Seq; // OUT: Sequence number
int Time; // OUT: Time for this packet
} PingInterface;
int ping(PingInterface *);
---------------------------------------------------------------------------
The ping.h header is included in the "netutils.h" header file, where
you have other functions that are network related.
In this times of multi-megabyte header files having a specific header
file for a function may look old fashioned and maybe it is, but it
allows the user to avoid name conflicts, for instance.