Networking Forums

Networking Forums > Computer Networking > Linux Networking > inetd and my own server

Reply
Thread Tools Display Modes

inetd and my own server

 
 
vertigo
Guest
Posts: n/a

 
      02-29-2004, 03:59 PM
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

 
Reply With Quote
 
 
 
 
Martin Blume
Guest
Posts: n/a

 
      02-29-2004, 05:32 PM
"vertigo" <(E-Mail Removed)> schrieb
> 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


Buffering? Try
printf("Test\n");
fflush(stdout);
and see if it gets better.

HTH
Martin




 
Reply With Quote
 
vertigo
Guest
Posts: n/a

 
      02-29-2004, 07:22 PM


> Buffering? Try
> printf("Test\n");
> fflush(stdout);
> and see if it gets better.


Thanx, it helped (and i changed wait to nowait in inetd.conf too)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/inetd.conf ??? michanux Linux Networking 1 07-16-2006 09:14 PM
inetd - more than one socket for daemon? bchm@op.pl Linux Networking 0 05-22-2006 07:50 PM
Specifying multiple IPs to listen for inetd Frank Linux Networking 2 08-24-2004 02:54 AM
inetd: dhcpd already running Stephan Eichler Linux Networking 1 11-27-2003 01:02 PM
Bash script via inetd = no joy tylernt Linux Networking 10 09-05-2003 08:53 PM



1 2 3 4 5 6 7 8 9 10 11