Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

inet_pton(3) [redhat man page]

inet_pton(3)						     Linux Programmer's Manual						      inet_pton(3)

NAME
inet_pton - Create a network address structure SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> int inet_pton(int af, const char *src, void *dst); DESCRIPTION
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. inet_pton(3) extends the inet_addr(3) function to support multiple address families, inet_addr(3) is now considered to be deprecated in favor of inet_pton(3). The following address families are currently supported: AF_INET src points to a character string containing an IPv4 network address in the dotted-quad format, "ddd.ddd.ddd.ddd". The address is converted to a struct in_addr and copied to dst, which must be sizeof(struct in_addr) bytes long. AF_INET6 src points to a character string containing an IPv6 network address in any allowed IPv6 address format. The address is converted to a struct in6_addr and copied to dst, which must be sizeof(struct in6_addr) bytes long. Certain legacy hex and octal formats of AF_INET addresses are not supported by inet_pton, which rejects them. RETURN VALUE
inet_pton returns a negative value and sets errno to EAFNOSUPPORT if af does not contain a valid address family. 0 is returned if src does not contain a character string representing a valid network address in the specified address family. A positive value is returned if the network address was successfully converted. SEE ALSO
inet_ntop(3) BUGS
AF_INET6 does not recognize IPv4 addresses. An explicit IPv6-mapped IPv4 address must be supplied in src instead. Linux Man Page 2000-12-18 inet_pton(3)

Check Out this Related Man Page

inet_ntop(3)						     Linux Programmer's Manual						      inet_ntop(3)

NAME
inet_ntop - Parse network address structures SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> const char *inet_ntop(int af, const void *src, char *dst, size_t cnt); DESCRIPTION
This function converts the network address structure src in the af address family into a character string, which is copied to a character buffer dst, which is cnt bytes long. inet_ntop(3) extends the inet_ntoa(3) function to support multiple address families, inet_ntoa(3) is now considered to be deprecated in favor of inet_ntop(3). The following address families are currently supported: AF_INET src points to a struct in_addr (network byte order format) which is converted to an IPv4 network address in the dotted-quad format, "ddd.ddd.ddd.ddd". The buffer dst must be at least INET_ADDRSTRLEN bytes long. AF_INET6 src points to a struct in6_addr (network byte order format) which is converted to a representation of this address in the most appropriate IPv6 network address format for this address. The buffer dst must be at least INET6_ADDRSTRLEN bytes long. RETURN VALUE
inet_ntop returns a non-null pointer to dst. NULL is returned if there was an error, with errno set to EAFNOSUPPORT if af was not set to a valid address family, or to ENOSPC if the converted address string would exceed the size of dst given by the cnt argument. SEE ALSO
inet_pton(3) BUGS
AF_INET6 converts IPv6-mapped IPv4 addresses into an IPv6 format. Linux Man Page 2000-12-18 inet_ntop(3)
Man Page

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

inet_pton function

(0 Replies)
Discussion started by: zheng
0 Replies

2. Programming

inet_pton function

Hello, First of all: please pardon my inexperience. I'm new to Unix/Linux. My apologies upfront :) I'm trying to use the inet_pton() function. I've created the below script based on what I found in the manual (man inet_pton): #include <sys/types.h> #include <sys/socket.h> #include... (4 Replies)
Discussion started by: zheng
4 Replies

3. Shell Programming and Scripting

Split file into multiple files depending upon first 4 digits

Hi All, I have a file like below: 1016D"ddd","343","1299" 1016D"ddd","3564","1299" 1016D"ddd","3297","1393" 1016D"ddd","32989","1527" 1016D"ddd","346498","1652" 2312D"ddd","3269","1652" 2312D"ddd","328","1652" 2312D"ddd","2224","2100" 3444D"ddd","252","2100" 3444D"ddd","2619","2100"... (4 Replies)
Discussion started by: deepakgang
4 Replies

4. Programming

inet_pton question

I use FreeBSD5.3,I use inet_pton under c language,like follows: if(inet_pton(AF_INET6,argv,&servaddr.sin6_addr)<=0){ printf("error"); } else{ printf("ok"); } Then I run above code, ./a.out 127.0.0.1 It shows "error"! I don't know why it don't show "ok",anyone could tell me the... (1 Reply)
Discussion started by: konvalo
1 Replies

5. UNIX for Dummies Questions & Answers

Search Pattern and add column

Hi, I have two files. file1 contents: aaa bbb ccc ddd eee fff ggg ddd www eee ggg dde qqq zzz hhh ddd file2 contents: mmm mmm mmm mmm Now I want to add file2 contents to end of lines in file1 where a line contains pattern "ddd" and it should look like this: file3 contents: aaa... (3 Replies)
Discussion started by: harjitsingh
3 Replies

6. Shell Programming and Scripting

Split Filename from Absolute Path

Hello, I have the string "/a/b/c/ddd.txt" and i want to get only the filename, in this case "ddd.txt". I have as something known in the script the pattern "/a/b/c/", so I`ve tried something like: echo "/a/b/c/ddd.txt" | cut -d "/a/b/c/" -f2 but it doesn`t go, any help?. thanks, bye (2 Replies)
Discussion started by: rubber08
2 Replies

7. Programming

IPv4 string->int

Does anyone know how to convert a IP address given as 'string' into a 'u_int32_t'? Are there any build any functions already? (1 Reply)
Discussion started by: Freaky123
1 Replies