/ft_ping

recoding the ping command

MIT LicenseMIT

ft_ping

recoding the ping command

function description return value
int gettimeofday (struct timeval *tv, struct timezone *tz) The function gettimeofday() can get and set the time as well as a timezone 0 for success, or -1 for failure (in which case errno is set appropriately).
---------- ------------- --------------
const char *inet_ntop (int af, const void *src, char *dst, socklen_t size) This function converts the network address structure src in the af address family into a character string. The resulting string is copied to the buffer pointed to by dst, which must be a non-null pointer. The caller specifies the number of bytes available in this buffer in the argument size On success, inet_ntop() returns a non-null pointer to dst. NULL is returned if there was an error, with errno set to indicate the error
int inet_pton (int af, const char *src, void *dst) This function converts the character string src into a network address structure in the af address family, then copies the network address structure to dst. The af argument must be either AF_INET or AF_INET6. dst is written in network byte order. The AF_INET and AF_INET address families are currently supported inet_pton() returns 1 on success (network address was successfully converted). 0 is returned if src does not contain a character string representing a valid network address in the specified address family. If af does not contain a valid address family, -1 is returned and errno is set to EAFNOSUPPORT
uint16_t ntohs (uint16_t netshort); converts the unsigned short integer netshort from network byte order to host byte order. uint16_t
uint16_t htons (uint16_t hostshort); converts the unsigned short integer hostshort from host byte order to network byte order. uint16_t
sighandler_t signal (int signum, sighandler_t handler) signal() sets the disposition of the signal signum to handler, which is either SIG_IGN, SIG_DFL, or the address of a programmer-defined function (a "signal handler") signal() returns the previous value of the signal handler, or SIG_ERR on error. In the event of an error, errno is set to indicate the cause
unsigned int alarm (unsigned int seconds) alarm() arranges for a SIGALRM signal to be delivered to the calling process in seconds seconds. If seconds is zero, any pending alarm is canceled. In any event any previously set alarm() is canceled. alarm() returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm
int usleep (useconds_t usec) The usleep() function suspends execution of the calling thread for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers The usleep() function returns 0 on success. On error, -1 is returned, with errno set to indicate the cause of the error
int socket (int domain, int type, int protocol); socket() creates an endpoint for communication and returns a file descriptor that refers to that endpoint. On success, a file descriptor for the new socket is returned. On error, -1 is returned, and errno is set appropriately.
int setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen); manipulate options for the socket referred to by the file descriptor sockfd. Options may exist at multiple protocol levels; they are always present at the uppermost socket level. On success, zero is returned for the standard options. On error, -1 is returned, and errno is set appropriately. Netfilter allows the programmer to define custom socket options with associated handlers; for such options, the return value on success is the value returned by the handler.
---------- ------------- --------------
---------- ------------- --------------
---------- ------------- --------------