Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

inet_pton(3) [php man page]

INET_PTON(3)								 1							      INET_PTON(3)

inet_pton - Converts a human readable IP address to its packed in_addr representation

SYNOPSIS
string inet_pton (string $address) DESCRIPTION
This function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropri- ate 32bit or 128bit binary structure. PARAMETERS
o $address - A human readable IPv4 or IPv6 address. RETURN VALUES
Returns the in_addr representation of the given $address, or FALSE if a syntactically invalid $address is given (for example, an IPv4 address without dots or an IPv6 address without colons). EXAMPLES
Example #1 inet_pton(3) Example <?php $in_addr = inet_pton('127.0.0.1'); $in6_addr = inet_pton('::1'); ?> CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now available on Windows plat- | | | forms. | | | | +--------+---------------------------------------------------+ SEE ALSO
ip2long(3), long2ip(3), inet_ntop(3). PHP Documentation Group INET_PTON(3)

Check Out this Related 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)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Obtaining IP address

(1 Reply)
Discussion started by: Raael
1 Replies

2. UNIX for Advanced & Expert Users

Changing Machine IP address

Hopefully someone can help with this. I need the command to change the IP address on a machine (7 Replies)
Discussion started by: kkinnon
7 Replies

3. UNIX for Dummies Questions & Answers

Changing IP address

Hi, I am going to shift my Unix workstation to another lab. So I need to change the IP address. Please tell me how to change the Network IP address, what is the commands, what to take care? Thank you very much and have a very nice day. (4 Replies)
Discussion started by: champion
4 Replies

4. 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

5. UNIX for Dummies Questions & Answers

df -h

Hi, I know there is a human readable mode of the 'df' command also known as 'df -h'. When I run that switch on most AIX boxes it doesn't work. My workplace currently has 10 AIX servers in which 2 can run df -h, but even a 'df' man page on those 2 boxes doesn't show any -h switch. What... (4 Replies)
Discussion started by: guile
4 Replies

6. UNIX for Dummies Questions & Answers

where is Ip address stored

I run - telnet adl001 (where adl001 is a box name) and it works Ok /etc/hosts file does not have resolution of the ip address for this name where it can be found ? Thanks (5 Replies)
Discussion started by: zam
5 Replies

7. UNIX for Advanced & Expert Users

getprotobyname replacement?

I've been tasked with converting our software from strictly an IPv4 environment to handling both IPv4 and IPv6. I'm very nearly done and everything seems to be progressing just fine. There's just one thing that's been nagging me for a while now, so I thought I'd enquire about this. I've read... (1 Reply)
Discussion started by: sszd
1 Replies

8. 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

9. Shell Programming and Scripting

how to detect ip address based location using PHP

I am interested in finding out if there is a reliable and economical way for extracting user's location based on his ip address, using php I tried to get the job done using ip2location.com, but I am not happy how it deals with result inconsistently. (2 Replies)
Discussion started by: siftin-com
2 Replies

10. Shell Programming and Scripting

Any idea on 3 Octet IP address ?

(4 Replies)
Discussion started by: jambesh
4 Replies

11. Linux

HOW TO DISABLE SIT0 in REDHAT LINUX 5.1

Hi All, I want to configure static IP4 address in my Linux system. I just found sit0 is enabled in my system. ifconfig -a returns sit0 Link encap:IPv6-in-IPv4, but there is no eth0. I tried with $ system-config-network & and changed static IP Add: 192.168.1.10 but no result after... (2 Replies)
Discussion started by: gohappy
2 Replies

12. Solaris

IPMP + IPv6 test address

Hi, inspired by this article, I decided to implement IPMP + IPv6 in Solaris 10. It worked for me only this way: 1. Setup # cat /etc/hostname* 10.23.10.113/24 broadcast + group data failover up <- hostname.e1000g0 0.0.0.0/24 broadcast + group data -failover deprecated up standby... (3 Replies)
Discussion started by: masloff
3 Replies

13. UNIX for Dummies Questions & Answers

Make netstat human readable?

Is there any way to make netstat output the information in a more human readable format? even if it's not exact? I don't even care if it has to round up/down to the nearest Meg to make it work. I wind up having to stare at netstat running for while and I wish I could get it to output things in a... (10 Replies)
Discussion started by: MrEddy
10 Replies

14. UNIX for Dummies Questions & Answers

'h' flag in du

Hey, all! Why is the "human readable" flag changing the behavior of du? And while I'm at it, can you make du only look at files, not directories. I often find myself wanting to find the largest file(s) in a dir or vol. Using 'find' itself, it seems you have to at least be able to guess the size of... (2 Replies)
Discussion started by: sudon't
2 Replies

15. Programming

How to parse .nessus file to get result in human readable format?

Scripting Language: bash shell script, python I want to parse .nessus file in human readable format. If any one have any ideas please help me. (2 Replies)
Discussion started by: sk151993
2 Replies