inetd and my own server

From: vertigo (none_at_microsoft.com)
Date: 02/29/04


Date: Sun, 29 Feb 2004 17:59:13 +0100

Hello
I wrote very simple server (called from inetd):
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv)
{
while(1)
     {
     printf("Test\n");
     sleep(1);
     }
return 0;
}

and i added in inetd.conf:
secure stream tcp wait root /home/high/p2p/inetd/time time

And when i try to telnet on that port i receive:
-bash-2.05b# telnet 10.0.3.1 10000
Trying 10.0.3.1...
Connected to Server.
Escape character is '^]'.
and it hangs...

But when i change my server code to:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv)
{
while(1)
     {
     printf("Test\n");
     return 0; /*!!!*/
     sleep(1);
     }
return 0;
}

everything works fine.
WHy ? Why can not i build servers called from inetd that do not send all
data imediately ?

Thanx



Relevant Pages