- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: getpeername() return 0 but with IP address "0....
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 05:51 PM
07-04-2006 05:51 PM
getpeername() return 0 but with IP address "0.0.0.0"
The server is listening on a specified port. When a connection request comes, the server accepts the request and then fork() a child. Then the server call getpeername() and getsockname() to get the client's and server's addresses. Unfortunately both two calls succeed and return addresses "0.0.0.0" and ports "0".
I looked up the manual and search through google, but didn't found any solutions. Do you have any ideas about this problem?
HP-UX B.11.23 9000/800 on PA-RISC
Fei
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 05:54 PM
07-04-2006 05:54 PM
Re: getpeername() return 0 but with IP address "0.0.0.0"
Check for IPv6 is enabled on your server ?
# ifconfig will show it.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 06:20 PM
07-04-2006 06:20 PM
Re: getpeername() return 0 but with IP address "0.0.0.0"
Here's the source code fragment:
struct sockaddr_in peerAddr, servAddr;
int addrlen = sizeof (sockaddr_in);
if (-1 == (getpeername(sockFd, (struct sockaddr *)&peerAddr, &addrlen)))
exitError("getpeername()");
addrlen = sizeof (sockaddr_in);
if (-1 == (getsockname(sockFd, (struct sockaddr *)&servAddr, &addrlen)))
exitError("getsockname()");
cout << "Peer IP: " << inet_ntoa(peerAddr.sin_addr) << " PORT: "<< ntohs(peerAddr.sin_port) << endl;
cout << "Serv IP: " << inet_ntoa(servAddr.sin_addr) << " PORT: " << ntohs(servAddr.sin_port) << endl;
Here's the output:
Peer IP: 0.0.0.0 PORT: 0
Serv IP: 0.0.0.0 PORT: 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 06:47 PM
07-04-2006 06:47 PM
Re: getpeername() return 0 but with IP address "0.0.0.0"
I'm not sure, because I didn't write any C stuff for years.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2006 08:01 PM
07-04-2006 08:01 PM
Re: getpeername() return 0 but with IP address "0.0.0.0"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2006 12:32 PM
07-05-2006 12:32 PM
Re: getpeername() return 0 but with IP address "0.0.0.0"
You might consider doing an memset to something other than "0" on the sockaddr so you can see if the calls are setting them to zero or simply not setting them at all.
Also, a tusc trace of the calls might be a good idea. Make it a verbose one.