Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EBADF whenever calling svctcp_create()

807575Feb 16 2004 — edited Feb 26 2004
Hello,

I have a problem creating a RPC TCP service on a specified port (because of a firewall).
The code I wrote works fine on OSF/1, AIX but prompts me with a "Bad file number" whenever I run it on SunOS.

Here is the code:

main(int argc, char *argv[])
{
if (argc == 4)
{
int i_program, i_version, i_portid, socketId;
SVCXPRT *transp;
struct sockaddr_in addr;

i_program = atoi(argv[1]);
i_version = atoi(argv[2]);
i_portid = atoi(argv[3]);
socketId = 0;
transp = NULL;
memset(&addr, 0, sizeof(addr));

pmap_unset(i_program, i_version);
if ((socketId = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("Error opening socket\n");
exit(2);
}
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(i_portid);
if (bind(socketId, (struct sockaddr *) (&addr), sizeof(addr)))
{
printf("Unable to bind TCP socket\n");
close(socketId);
exit(2);
}
transp = (SVCXPRT *)svctcp_create(socketId, 0, 0);
if (transp == NULL)
{
printf("Unable to create a TCP service\n");
close(socketId);
exit(2);
}
if (! svc_register(transp, i_program, i_version, NULL, IPPROTO_TCP))
{
svc_unregister(i_program, i_version);
printf("Unable to register (PGM = %d, VER = %d, TCP)\n", i_progr
am, i_version);
exit(2);
}
}
else
{
printf("Please enter Program number, version number and Port number\n");
}
exit(0);
}

Any help would be greatly appreciated,

Thank you,

jraffy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2004
Added on Feb 16 2004
1 comment
138 views