Operating System - HP-UX
1753808 Members
7960 Online
108805 Solutions
New Discussion юеВ

Re: How can i make an inetd process?

 
msbinu
Advisor

How can i make an inetd process?

Hi All ,

I have a client an server among which i want to make the server an inetd process.

I have enries in etc/services and etc/inetd.conf
The enries looks like below
etc/services
servername 5551/tcp
etc/inetd.conf

servername stream tcp nowait root /binu

Now if I try to run my client ,the connection with server is not getting established

My client code to connect ins ome thng like this
sd = socket (AF_INET, SOCK_STREAM, 0); CHK_ERR(sd, "socket");

memset (&sa, '\0', sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr ("127.0.0.1"); /* Server IP */
sa.sin_addr.s_addr = inet_addr ("164.164.27.88");
sa.sin_port = htons (5551); /* Server Port number */

err = connect(sd, (struct sockaddr*) &sa,
sizeof(sa)); CHK_ERR(err, "connect");

/* ----------------------------------------------- */
/* Now we have TCP conncetion. Start SSL negotiation. */

ssl = SSL_new (ctx); CHK_NULL(ssl);
SSL_set_fd (ssl, sd);
err = SSL_connect (ssl); CHK_SSL(err);


and my server code is like below

/* Prepare TCP socket for receiving connections */

listen_sd = socket (AF_INET, SOCK_STREAM, 0); CHK_ERR(listen_sd, "socket");

memset (&sa_serv, '\0', sizeof(sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (5551); /* Server Port number */

err = bind(listen_sd, (struct sockaddr*) &sa_serv,
sizeof (sa_serv)); CHK_ERR(err, "bind");

/* Receive a TCP connection. */

err = listen (listen_sd, 5); CHK_ERR(err, "listen");

client_len = sizeof(sa_cli);
//Binu
sd = accept (listen_sd, (struct sockaddr*) &sa_cli,(int *) &client_len);
CHK_ERR(sd, "accept");
close (listen_sd);


can any one please help me?

Thanks
Binu
4 REPLIES 4
BLETARD Philippe
Occasional Contributor

Re: How can i make an inetd process?

Hello,
Did you force inetd to reload the config file by inetd -c ?

And in your inetd.conf, you must have the complete path to your server and the command to execute your server itself... kind of
servername stream tcp nowait root /binu binu
msbinu
Advisor

Re: How can i make an inetd process?

Hi ,

I have given all entries.
Actually now I have noticed that the connection is establishing, but the bind in the server is failing
BLETARD Philippe
Occasional Contributor

Re: How can i make an inetd process?

Hello Binu,

I don't remember well but as it's inetd which is managing the socket connection, I'm not sure you've to do a 'bind' in your server... There's also a faq you can check at http://www.manualy.sk/sock-faq/unix-socket-faq-4.html
msbinu
Advisor

Re: How can i make an inetd process?

Hi ,

Actually i have removed the bind calls as it is not required .Now the problem is that, I m not sure to which sd i have to do a read and write .

( I m using SSL server.Hence i m using SSL_read ,SSL_write etc )

Binu