HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
p
pstat(2) pstat(2)
count = pstat_getstream(psfstream, sizeof(struct pst_stream), 3, 0,
&(psf.psf_fid));
if (count > 0) {
if ((psfstream[0].val.head.pst_hi_fileid ==
psf.psf_hi_fileid) &&
(psfstream[0].val.head.pst_lo_fileid ==
psf.psf_lo_fileid) &&
(psfstream[0].val.head.pst_hi_nodeid ==
psf.psf_hi_nodeid) &&
(psfstream[0].val.head.pst_lo_nodeid ==
psf.psf_lo_nodeid)) {
printf("Success\n");
printf("The major number of the stream is %d\n",
psfstream[0].val.head.pst_dev_major);
} else {
printf("State changed\n");
}
} else {
perror("pstat_getstream()");
}
} else {
perror("pstat_getfile2");
}
close(fd);
}
/*
* Example 10: Acquire detailed information about a socket
*/
main()
{
struct pst_fileinfo2 psf;
struct pst_socket psfsocket;
int rv, count, fd;
fd = socket(AF_INET, SOCK_STREAM, 0);
rv = pstat_getfile2(&psf, sizeof(psf), 0, fd, getpid());
if (rv == 1) {
/*
* Ask for socket information.
*/
count = pstat_getsocket(psfsocket, sizeof(struct pst_socket),
&(psf.psf_fid));
if (count == 1) {
if ((psfsocket.pst_hi_fileid == psf.psf_hi_fileid) &&
(psfsocket.pst_lo_fileid == psf.psf_lo_fileid) &&
(psfsocket.pst_hi_nodeid == psf.psf_hi_nodeid) &&
(psfsocket.pst_lo_nodeid == psf.psf_lo_nodeid)) {
printf("Success\n");
printf("The type of socket is %d, should be %d\n",
psfsocket.pst_type, PS_SOCK_STREAM);
} else {
printf("State changed\n");
}
} else {
perror("pstat_getsocket()");
}
} else {
HP-UX 11i Version 1: September 2005 − 14 − Hewlett-Packard Company Section 2−−251