|
|
|
Example:
Suppose: struct sockaddr_in dest_addr; contains an IP address in network byte order |
int main(int argc, char **argv)
{
struct sockaddr_in dest_addr; /* Destination socket address */
...
/* =============================================================
argv[1] is the string containg the dotted decimal IP address
============================================================= */
if ( ( dest_addr.sin_addr.s_addr = inet_addr( argv[1] ) ) == -1 )
{
printf("Dotted IP-address must be of the form a.b.c.d\n");
exit(1);
}
...
}
|
|
How to run the program:
|