Operating System - HP-UX
1756988 Members
3670 Online
108858 Solutions
New Discussion юеВ

Re: socket API issue on HP PA_RISC 11.11

 
madhavabk
Regular Advisor

socket API issue on HP PA_RISC 11.11

Hi All,

I have written a small program to create datagram socket as given in below lines.

struct sockaddr_in saddr;
int sockfd;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if ( sockfd < 0 )
{
perror("dgramTest.c:23 socket");
exit(2);
}

This program i am compiling like., /opt/ansic/bin/cc gramTest.c -o /var/tmp/test

This program runs fine when system is up and running.

But this program fails when i run it as part of init service from following script while system is booting.
The initscript looks like.,
#!/bin/sh
/var/tmp/test

The init script for this has priority S10 in /sbin/rc3.d.

The message i am getting on console is
dgramTest.c:23 socket: Operation not supported
Which is basically perror() output from above program lines.

Can you tell me is there any mistake in my program or there are some limitation to know.

Thanks,
Madhava

3 REPLIES 3
RAC_1
Honored Contributor

Re: socket API issue on HP PA_RISC 11.11

This is most proablly because, you are starting program much earlier than netwotk stuff starts.

S10 will be started first than S20 and so on. Put this script as last starting (choose S number accordingly) script. By then all required programs/apps would have been started. (Like network sub-system, network interfaces etc.)
There is no substitute to HARDWORK
madhavabk
Regular Advisor

Re: socket API issue on HP PA_RISC 11.11

Hi RAC,

I have changed priority to S991 then also i can see the issue.

Moreover, if my init script use ifconfig lan0 command then this command also logs error like

ifconfig: socket: Operation not supported
Output from "/sbin/rc3.d/S991mydaemon start":
----------------------------
lan0: flags=1843
inet 10.114.55.57 netmask ffffff00 broadcast 10.114.55.255

So i am not able to get what should be the priority.

Thanks,
Madhava
madhavabk
Regular Advisor

Re: socket API issue on HP PA_RISC 11.11

This issue is not because of:
1. rc level chosen
2. initd may not started before running our program.

Root cause:
===========
I feel on HPUX there is problem with getting
socket descriptors during system bootup time.

Some time there may be chances that it may get socket descriptor less that 2. 0-2 are for file I/O hence socket operation on them is not correct, hence i was getting error as Socket: Operation not supported.

But when i created some dummy descriptors before my socket API use in program this problem got fixed.

Hence it could be OS problem rather that application problem. We can use dummy descriptor opening method as work around for those program who need creation of sockets during system boot time.

Thanks,
Madhava