inet_pton question


 
Thread Tools Search this Thread
Top Forums Programming inet_pton question
# 1  
Old 07-08-2008
Question inet_pton question

I use FreeBSD5.3,I use inet_pton under c language,like follows:
if(inet_pton(AF_INET6,argv[1],&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 reason and how to do it?

Thanks in advance!
Best regards,
konvalo
# 2  
Old 07-18-2008
inet_pton() returns 0 if the source string does not contain a character string representing a valid network address in the specified address family. You might want to try feeding it an ipv6 address-type character string.

Last edited by fsahog; 07-18-2008 at 09:47 PM.. Reason: to make it better
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Question about $*

Hi, I have shell scrit code like below, but I have need few clarification on this. I have explained my understanding and doubts after this code. abcd() { print $(date +%y%m%d:%H%M%S) "$*" } exec >> /root/file1.log 2>&1 My understanding is abcd() is a function it... (3 Replies)
Discussion started by: stew
3 Replies

2. UNIX for Dummies Questions & Answers

Help me these Question??

1. How the Unix system identify the Other User to access for file permission? 2. What command we use to convert the extension of a file name? 3. What command use to convert other editing file to Unix based text file? Please answer of these Question???Its necessary for me?? (3 Replies)
Discussion started by: pradipta_pks
3 Replies

3. Shell Programming and Scripting

Another question regarding yes

I have a program that takes two responses, for example: ./eatfruit <stdout> Enter fruit: Do you want to eat fruit?: <end stdout> If I do this yes banana ./eatfruit <stdout> Enter fruit: banana (2 Replies)
Discussion started by: nj78
2 Replies

4. UNIX for Dummies Questions & Answers

I/O question

Hi, I have a simple .ksh file that list the contents of a folder. The contents of the folder need to be checked (make sure they are there). I have the output printed to a log. I then FTP to a windows server where the log is read. The problem is when I read the log file in windows there are... (1 Reply)
Discussion started by: bonekrusher
1 Replies

5. UNIX for Dummies Questions & Answers

a question

I was experimenting with redirection. Manual says >&digit --> standard output is redirected to the file descriptor digit I tried exec 3>myout exec >&3 This sent all the output to myout. Nothing was coming on the screen. I was thinking duplication will result in output similar to what... (7 Replies)
Discussion started by: ranj@chn
7 Replies

6. UNIX for Dummies Questions & Answers

A question?

using my unix os, can i do any autoexec.bat editing in order to execute selected programs that i use most often? :confused: (1 Reply)
Discussion started by: alecks1975
1 Replies

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

8. UNIX for Dummies Questions & Answers

cd-r vs. cd-rw question

I'm trying to put together a script that will burn some data to a cd....is there a way to tell from the command line whether the cd in the drive is a cd-r or a cd-rw? I'd like to blank the cd 1st if it's a cd-rw, but I want to automate this instead of asking for user input. Thanks!! (4 Replies)
Discussion started by: jalburger
4 Replies

9. UNIX for Dummies Questions & Answers

Next Question:

what is the function of swap in linux why i have to create apsolutely a particion for the swap when i install (i installed lnx4win mandrake and made an automat. disk particion and the install program one of my disk partitions that was 3gb devidet in 4 one native 700mb swap 600mb and the others i... (1 Reply)
Discussion started by: user666
1 Replies
Login or Register to Ask a Question