02-05-2008
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 that getprotobyname(), and it's reentrant counterpart (getprotobyname_r()) are obsolete. I've found links indicating this, but they don't say what the replacement for these are. If it's getaddrinfo(), (which I've been using to replace just about everything) then I'm a little confused. getaddrinfo() always seems to return IPPROTO_IP, regardless of the combination of hints. For example, calling getprotobyname_r ("UDP"...) returns IPPROTO_UDP for the protocol. Calling getaddrinfo(NULL, "0", hints,...) with hints set to...
family = AF_UNSPEC
socktype = SOCK_DGRAM
protocol = IPPROTO_UDP
...returns IPPROTO_IP for the info returned for both IPv4 and IPv6. It also doesn't matter whether or not an actual host and/or port (replacing the NULL and "0" respectively) are put in the call to getaddrinfo().
If the result of this is then to be used to create a socket, then won't the socket get created with the wrong protocol value?
What's weird is everything actually works just fine. That includes TCP, UDP, and multicast sockets. I'm just a little confused and don't quite understand what exactly is going on.
I'd appreciate any insight anyone can provide. Thanks.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have two files:
file1:
somedata
<html>
<head>
This is sample statement
......
......
</head>
</html>
somedata
file2:
olga 81 91 B A
rene 82 92 B A
zack 83 93
Expextd Result: (2 Replies)
Discussion started by: rajx
2 Replies
2. Shell Programming and Scripting
Hi,
I am working on a command that replaces some occurrences of quotation marks in file. The quotation mark cannot be the first or the last character in line and cannot be preceded or followed by a comma.
I am not an expert in regular expressions, but I managed to create the following... (2 Replies)
Discussion started by: piooooter
2 Replies
3. Shell Programming and Scripting
Hi
Can anyone provide me the replacement of sed with xargs perl syntax for the below
sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//'
This should be without looping has to take minimal time for search (0 Replies)
Discussion started by: dbsurf
0 Replies
4. UNIX for Dummies Questions & Answers
There is a requirement that i need to replaced a pattern by another pattern in all the files in my entire file system. there are 1000s of file in the system. let the pattern is "calcuta". i have to replace this pattern by "kolkata" in all those files which contain "calcuta".
I am only able to... (12 Replies)
Discussion started by: palash2k
12 Replies
5. Shell Programming and Scripting
Hi All,
I have below file which has data in below format.
#$ | AB_100
| AB_300
()| AB_4
@*(% | AB-789
i want o/p as below format.
| AB_100
| AB_300
| AB_4
| AB-789
So here there is no standard format.
How we can achieve the same in unix ?
Regards, (3 Replies)
Discussion started by: gander_ss
3 Replies
6. Shell Programming and Scripting
This seems like it should be an easy problem, but I'm a noob and I can't figure it out. I'm trying to use sed, but would be happy to use anything that does the job.
I am trying to trim off a fixed number of unknown characters from 2 different : delimited fields while keeping the intervening... (4 Replies)
Discussion started by: helix_w
4 Replies
7. Shell Programming and Scripting
Hi
pls help me for below;
i have a file .content is :
===================
uid,pcsPricingPlan,refPcsQosProfName
821910002022,smartlimit,SGSNQOS1
i have to replace the value of uid and pricingplan by a unix script.
may be the value would be next line or any where in the file.
pls... (9 Replies)
Discussion started by: Aditya.Gurgaon
9 Replies
8. UNIX for Dummies Questions & Answers
my filename.txt looks like this:
2079951061790 SCK0000891539000000000000021600R
2079951061790 SCK0000901487000000000000028900R
2079951061790 SCK0000903092000000000000021300R
2079951074758 ... (9 Replies)
Discussion started by: tjmannonline
9 Replies
9. HP-UX
I recently picked up an HP9000 server running HPUX. I would like to replace the CRT terminal console with something I can use a flat panel monitor. Any suggestions would be greatly appreciated. (1 Reply)
Discussion started by: Stevebei
1 Replies
10. Solaris
Hello,
I am getting below error in fmadm output. This server is not in support, so can't reach them. Is it showing that motherboard is faulty and should be replaced ? It was rebooted a week back and then, there were no errors
# fmadm faulty
--------------- ------------------------------------ ... (1 Reply)
Discussion started by: solaris_1977
1 Replies
LEARN ABOUT DEBIAN
explain_getaddrinfo_or_die
explain_getaddrinfo_or_die(3) Library Functions Manual explain_getaddrinfo_or_die(3)
NAME
explain_getaddrinfo_or_die - network address translation and report errors
SYNOPSIS
#include <libexplain/getaddrinfo.h>
void explain_getaddrinfo_or_die(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
DESCRIPTION
The explain_getaddrinfo_or_die function is used to call the getaddrinfo(3) system call. On failure, an explanation will be printed to
stderr, obtained from explain_getaddrinfo(3), and then the process terminates by calling exit(EXIT_FAILURE).
This function is intended to be used in a fashion similar to the following example:
explain_getaddrinfo_or_die(node, service, hints, res);
node The node, exactly as to be passed to the getaddrinfo(3) system call.
service The service, exactly as to be passed to the getaddrinfo(3) system call.
hints The hints, exactly as to be passed to the getaddrinfo(3) system call.
res The res, exactly as to be passed to the getaddrinfo(3) system call.
Returns:
This function only returns on success. On failure, prints an explanation and exits.
SEE ALSO
getaddrinfo(3)
network address and service translation
explain_getaddrinfo(3)
explain getaddrinfo(3) errors
exit(2) terminate the calling process
COPYRIGHT
libexplain version 0.52
Copyright (C) 2008 Peter Miller
explain_getaddrinfo_or_die(3)