HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Emulate parts of netstat functionality through...
Operating System - HP-UX
1830930
Members
2429
Online
110017
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
10-01-2001 01:58 AM
10-01-2001 01:58 AM
Emulate parts of netstat functionality through socket hack
Hi system hackers / networkers,
I couldn't quite make up my mind which would be the appropriate section for this posting (either Languages or Networking).
Indeed, this isn't anything especially HP-UX specific, but rather common Unix BSD Socket fair.
But I'm sure there are many experienced system hackers among you sysadmins.
I wish to write a wee prog / script which stats sockets of AF_INET *without* falling back to a system call to netstat.
I would want to do this in Perl with the Socket module, or the more comfortable OO module IO::Socket (which inherits from IO::Handle).
I know that the system calls of the socket library are 1:1 adaptations to Perl so any suggestions in C would also be very welcome.
Having read quite a bit about socket programming in Perl I now would know how to open a socket, bind it to a port, put it into listening mode, and make it accept connections.
Even how to trap dreaded PIPE signals, use syslog, change euid, chroot, disociate from the terminal, auto-background and serve clients, preforking, multiplexing, or simple forking.
I also read how to write clients that connect to a server.
What I didn't find though, was how to simply stat already established (or listening) sockets, say to simply count the number of connectios to a certain port.
As a last resort I think I could get the sources of a GNU netstat, and try to understand how they did it.
But I thought that maybe some of you also know, and could give me a little hint.
Many thanks
Ralph
I couldn't quite make up my mind which would be the appropriate section for this posting (either Languages or Networking).
Indeed, this isn't anything especially HP-UX specific, but rather common Unix BSD Socket fair.
But I'm sure there are many experienced system hackers among you sysadmins.
I wish to write a wee prog / script which stats sockets of AF_INET *without* falling back to a system call to netstat.
I would want to do this in Perl with the Socket module, or the more comfortable OO module IO::Socket (which inherits from IO::Handle).
I know that the system calls of the socket library are 1:1 adaptations to Perl so any suggestions in C would also be very welcome.
Having read quite a bit about socket programming in Perl I now would know how to open a socket, bind it to a port, put it into listening mode, and make it accept connections.
Even how to trap dreaded PIPE signals, use syslog, change euid, chroot, disociate from the terminal, auto-background and serve clients, preforking, multiplexing, or simple forking.
I also read how to write clients that connect to a server.
What I didn't find though, was how to simply stat already established (or listening) sockets, say to simply count the number of connectios to a certain port.
As a last resort I think I could get the sources of a GNU netstat, and try to understand how they did it.
But I thought that maybe some of you also know, and could give me a little hint.
Many thanks
Ralph
Madness, thy name is system administration
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 10:00 AM
10-02-2001 10:00 AM
Re: Emulate parts of netstat functionality through socket hack
There's about 7000 lines of C code in netstat on my FreeBSD system. You can get the code at www.freebsd.org - I'm sure it's in there somewhere.
I think this is what you're looking for:
struct ngpcb *this, *next;
struct ngpcb ngpcb;
struct ngsock info;
struct socket sockb;
/* Read in socket structure */
kread((u_long)ngpcb.ng_socket, (char *)&sockb, sizeof(sockb));
I think this is what you're looking for:
struct ngpcb *this, *next;
struct ngpcb ngpcb;
struct ngsock info;
struct socket sockb;
/* Read in socket structure */
kread((u_long)ngpcb.ng_socket, (char *)&sockb, sizeof(sockb));
No matter where you go, there you are.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2001 02:34 AM
10-04-2001 02:34 AM
Re: Emulate parts of netstat functionality through socket hack
Hi Vincent,
thanks for looking at netstat's sources.
I would have done this with my Linux distro's netstat as well.
Blimy, 7000 lines of code?
That's what I sort of feared, and why I posted here.
Unfortunately it looks as there aren't many HP-UX admin folks interested in this stuff, gathering from the overwhelming response to this post :-(
thanks for looking at netstat's sources.
I would have done this with my Linux distro's netstat as well.
Blimy, 7000 lines of code?
That's what I sort of feared, and why I posted here.
Unfortunately it looks as there aren't many HP-UX admin folks interested in this stuff, gathering from the overwhelming response to this post :-(
Madness, thy name is system administration
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP