Problems writing a port responder under HP-UX 9 (inetd responder)

Problems writing a port responder under HP-UX 9 (inetd responder)

Post by Don Perki » Thu, 29 May 1997 04:00:00



H E L P ! ! !

[Please email your response to me as well as posting to the ng.
Thanks.]

I am writing a port responder program (triggered by inetd) and am
having a rather odd problem:  As long as I am only sending output (to
'stdout') the program runs fine.  I can use the Windows telnet program
to connect to my custom port and I see the "Hello World" message from
my program.

The problem begins with any calls to an input routine using 'stdin'
(such as fscanf(), read(), getchar()).  While the program runs fine
when called from the shell, it fails when called by inetd.  I don't
even get the "Hello World" message.

I have tried turning on logging (inetd -l) to find out why the program
is failing, but cannot find anything in the system logs.

SPECS:
======

I am using HP-UX version A.09.04 with the default cc compiler (K&R
79).

The following entry is in /etc/services:
   pbpcgvi  7244/tcp

The following entry is in /etc/inetd.conf:
   pbpcgvi stream tcp nowait root /users/djperk/pbpcgvi pbpcgvi

A sample program that works as a port responder is:
-----------------------------------------------------------
#include <stdio.h>

main()
{
   fprintf(stdout,"Port responder test.\n\r\n\r");

Quote:}

-----------------------------------------------------------

And the a sample program that fails as a port responder is:
-----------------------------------------------------------
#include <stdio.h>

main()
{
   char inp_char;

   fprintf(stdout,"Port responder test.\n\r\n\r");
   inp_char = getchar();
   fprintf(stdout,inp_char);

Quote:}

-----------------------------------------------------------

----------------------------------------------------------------------

----------------------------------------------------------------------

 
 
 

Problems writing a port responder under HP-UX 9 (inetd responder)

Post by Andrew Giert » Thu, 29 May 1997 04:00:00


 Don> The problem begins with any calls to an input routine using 'stdin'
 Don> (such as fscanf(), read(), getchar()).  While the program runs fine
 Don> when called from the shell, it fails when called by inetd.  I don't
 Don> even get the "Hello World" message.
 [...]
 Don> And the a sample program that fails as a port responder is:
 Don> -----------------------------------------------------------
 Don> #include <stdio.h>

 Don> main()
 Don> {
 Don>    char inp_char;

 Don>    fprintf(stdout,"Port responder test.\n\r\n\r");

fflush(stdout);

 Don>    inp_char = getchar();
 Don>    fprintf(stdout,inp_char);

should be fprintf(stdout,"%c",inp_char); or similar.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>

 
 
 

1. write() to a serial port in HP-UX 10 doen not write

the following code writes neatly if  oaccname is a standard file but if  it
is "/dev/tty1p7" on hp-ux 10 write() returns as if the data was written but
nothig is received at the port..

cat > /dev/tty1p7       also behaves that way but I can send to the port
thru cu -ltty1p7...

any ideas?

Thanxs

if ((oaccfilno=open(oaccname,(O_RDWR | O_NONBLOCK | O_NOCTTY))) >= 0) {

...
void tra(const int oaccfilno,
             const char *acctra, const char *stx, const char *etx)
{
(
   int h, i, j, k;
   fd_set writefds;
   h = strlen(stx);
   i = 0;
   j = 0;
   k = 0;

   while(i < h) {
      FD_ZERO(&writefds);
      FD_SET(oaccfilno,&writefds);
      k = select(oaccfilno+1, NULL, &writefds, NULL, NULL);
      j = write(oaccfilno, &acctra[i], (h - i));

      if (j > 0) i+= j;
   }
--

2. Sendmail "user unknown"

3. Who initiates DNS tcp 53 port requester or responder?

4. Sockets: Too many open files on a sequent under dynix

5. vacation automated mail responder problem - HELP!

6. Xgopher

7. Error building jdk 1.4.1 on 5.0-p4

8. Difference between HP-UX 10.10 and HP-UX 10.20

9. Auto Responder for E-MAIL ???

10. auto-responder

11. Automated E-Mail Responder????

12. Auto Responder