Sponsored Content
Full Discussion: IPv4 string->int
Top Forums Programming IPv4 string->int Post 302655821 by pludi on Wednesday 13th of June 2012 07:39:57 PM
Old 06-13-2012
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to convert a string to int

Hi, i want to read a text file whose content(single line) will be a number like 1 or 2 or 3 ..... what i want to do is to read the file and increment the content of the file, using unix scripting. Regards, Senthil Kumar Siddhan. (2 Replies)
Discussion started by: senthilk615
2 Replies

2. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

3. Shell Programming and Scripting

Compare string output to int value?

Hi, i'd like to implmeent emergency shutdown script in case our AC dies and the temperature rises too high. I can get core temperatures with: sensors | grep Core | cut -c15-16 Result is: 23 18 18 13 21 18 15 17 How can I check if any of the cores is above eg. 80 (that's C of... (2 Replies)
Discussion started by: zapp0
2 Replies

4. Programming

how to covert string into 2 diff int

i got a string E.g "12.67" how do i convert it into a int so that a= 12 b =67 any one can guide me along? (8 Replies)
Discussion started by: xiaojesus
8 Replies

5. Shell Programming and Scripting

From string to int ?

hello guys i m new to shell scripting and can't find out why this structure is not right I m guessing this happens because $LINESUM is a string . so how can i do this ? i want my script to do so many loops as the number of the lines of one custom file. #!/bin/bash echo give me path name... (5 Replies)
Discussion started by: xamxam
5 Replies

6. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

7. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

8. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

9. Programming

Splitting string and storing in int

I have a string containing 2 integers separated by /, for example 12/8 or 8/6 am want to store the numbers in two integers. (3 Replies)
Discussion started by: kristinu
3 Replies

10. Shell Programming and Scripting

Convert int to string in python

Hi, I have column 5 in a file which contains string like this for ex. RP11-125O5.2 SLCO1B1 CAPN1 FRMPD2 TXNL4B So I do by data = )] ValueError: invalid literal for int() with base 10: 'R' Can someday tell me how to convert this column into int successfully. Thank You in... (7 Replies)
Discussion started by: rossi
7 Replies
inet6(3N)																 inet6(3N)

NAME
inet_pton(), inet_ntop() - Internet address manipulation routines for IP Version 4 and later SYNOPSIS
DESCRIPTION
The functions and are new with IP Version 6 (IPv6) and work with both IP Version 4 (IPv4) and IPv6 addresses. The letters "p" and "n" stand for and The presentation format for an address is often an ASCII string and the numeric format is the binary value that goes into a socket address structure. The ASCII string is either the IPv4 address in dot notation or an IPv6 address in colon notation. An example of an ASCII string is or The binary value is the hex representation of the IPv4/IPv6 address. This binary value resides in the structure for IPv4 address and in the structure for IPv6 address. (Refer to the inet(3N) manpage for more details.) The functions and are opposite of each other. The function converts an ASCII address string to binary address, and the function converts a binary address into ASCII address string. Also, these are equivalent to and respectively. The inet_pton() Function The function converts an address in its standard text presentation form into its numeric binary form. The af argument specifies the family of the address. Currently, the and address families are supported. The src argument points to the IPv6/IPv4 address string being passed in. The argument points to a buffer in which the function stores the numeric address. The address is returned in network byte order. returns if the conversion succeeds, if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 address string, or with errno set to if the af argument is unknown. The calling application must ensure that the buffer referred to by dst is large enough to hold the numeric address (e.g., 4 bytes for or 16 bytes for If the af argument is the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd where ddd is a one to three digit decimal number between 0 and 255. Note that many implementations of the existing and functions accept nonstandard input: octal numbers, hexadecimal numbers, and fewer than four numbers. does not accept these formats. If the af argument is then the function accepts a string in one of the standard IPv6 text forms. (Refer to the IPv6 address notation below for more details). The inet_ntop() Function The function converts a numeric address into a text string suitable for presentation. The af argument specifies the family of the address. This can be or The src argument points to a buffer holding an IPv4 address if the af argument is or an IPv6 address if the af argument is The dst argument points to a buffer where the function will store the resulting text string. The size argument specifies the size of this buffer. The application must specify a non-NULL dst argument. For IPv6 addresses, the buffer must be at least 46-octets. For IPv4 addresses, the buffer must be at least 16-octets. In order to allow applications to easily declare buffers of the proper size to store IPv4 and IPv6 addresses in string form, the following two constants are defined in The function returns a pointer to the buffer containing the text string if the conversion succeeds, and NULL otherwise. Upon failure, errno is set to if the af argument is invalid, or if the size of the result buffer is inadequate. IPv6 Address Notation The IPv6 address is bytes long. Example of an IPv6 address is as shown below: The 128 bits are written as eight 16-bit integers separated by colons. Each integer is represented by four hexadecimal digits. In the initial stages all the 128 bits will not be used, hence, it is very likely that there will be many zeros. Hence the IP address in such a scenario will look like this: The above address can be represented in a compact fashion, by replacing a set of consecutive null 16-bit numbers by two colons. The above address can now be re-written as follows: Expanding the abbreviation is very simple. Align whatever is at the left of the double colon to the left of the address: these are the leading 16-bit words. Then align whatever is at the right of the colons to the right of the address and fill up with zeros. The double-colon convention can be used only once inside an address. To support the transition from IPv4, two special IPv6 addresses are supported. They are addresses and addresses. IPv4-Compatible Addresses Description and Example IPv4-compatible addresses can be converted to and from the older IPv4 network address format. They are used when IPv6 systems need to com- municate with each other, but are separated by an IPv4 network. IPv4-compatible addresses are formed by prepending 96 bits of zero, to a valid, 32-bit IPv4 address. For example, the IPv4 address of can be converted to the IPv6 address by first converting each decimal number separated by dots (".") to a 2-digit hexadecimal value, and concatenate into 4-digit hex values between colons (":") as listed below. In addition, leading zeros may be omitted for each hex number between the colons. Therefore, this may be written as the following IPv6 address: We can retain the dot-decimal format and re-write the above address as The above address is also a valid IPv4-compatible IPv6 address. IPv4-Mapped Addresses Description and Example IPv4-mapped addresses indicate systems that do not support IPv6. They are limited to IPv4. An IPv6 host can communicate with an IPv4-only host using the IPv4-mapped IPv6 address. IPv4-mapped addresses are formed by prepending 80 bits of zero, and 16 bits of one's, to a valid 32 bit IPv4 address. An IPv4 address of when mapped to IPv6, it becomes: or AUTHOR
These routines were developed by the University of California, Berkeley. SEE ALSO
gethostent(3N), getnetent(3N), inet(3N), hosts(4), networks(4). inet6(3N)
All times are GMT -4. The time now is 05:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy