06-13-2012
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?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT OSF1
inet_pton
inet_pton(3) Library Functions Manual inet_pton(3)
NAME
inet_pton - Converts a text string to a numeric address
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <arpa/inet.h>
int inet_pton ( int af, const char *src, void *dst) ;
PARAMETERS
Specifies the address family. Valid values are AF_INET for an Internet Protocol Version 4 (IPv4) address and AF_INET6 for an IPv6 address.
Points to the address text string to be converted. Points to a buffer that is to contain the numeric address.
DESCRIPTION
The use of this routine is deprecated. Use the getaddrinfo(3) routine instead; it is also protocol-independent.
The inet_pton() function converts a text string to a numeric value in Internet network-byte order.
If the af parameter is AF_INET, the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd
In this format, ddd is a one to three digit decimal number between 0 and 255.
If the af parameter is AF_INET6, the function accepts a string in the following form: x:x:x:x:x:x:x:x
In this format, x is hexadecimal value of a 16-bit piece of the address.
IPv6 addresses can contain long strings of zero (0) bits. To make it easier to write these addresses, you can use double colon characters
(::) one time in an address to represent 1 or more 16-bit groups of zeros.
For mixed IPv4 and IPv6 environments, the following form is also accepted: x:x:x:x:x:x:ddd.ddd.ddd.ddd
In this form, x is hexadecimal value of a 16-bit piece of the address and ddd is a one to three digit decimal value between 0 and 255 that
represents the IPv4 address. See RFC 2373 for more information on IPv6 addressing formats.
The calling application is responsible for ensuring that the buffer referred to by the dst parameter is large enough to hold the numeric
address. AF_INET addresses require 4 bytes and AF_INET6 addresses require 16 bytes.
RETURN VALUES
Upon successful completion, the inet_pton() function returns 1. If the input string is not a valid IPv4 dotted-decimal string or a valid
IPv6 address string, the function returns 0. If any other error occurs, the function returns -1.
ERRORS
If the inet_pton() routine call fails, errno is set to one of the following values: The address family specified in the af parameter is
unknown.
RELATED INFORMATION
Functions: getaddrinfo(3), inet_ntop(3).
RFC 2373, IP Version 6 Addressing Architecture delim off
inet_pton(3)