Jump to content
  • Advertisement
Sign in to follow this  
dcosborn

Keep listener alive

This topic is 4783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got one computer connecting to another via netcat. However, when I disconnect the client via ctrl-c, the the netcat listener also terminates. How can I keep the listener alive?

Share this post


Link to post
Share on other sites
Advertisement
Well, you could run netcat in a loop. There's some drawbacks there, though. What are you trying to do, anyway?

Share this post


Link to post
Share on other sites
Well I'm piping my game's log output to the second computer via netcat. When the game terminates, the netcat connection is still alive. I have to press ctrl-c on the client to actually close the connection. And when I do this, the listener on the server dies too. So I have to start the listener again next time I want to run the game. I'm a Linux noob - how do you make it loop? I've read about a -L option but Gentoo netcat doesn't seem to have it.

Share this post


Link to post
Share on other sites
Woohoo Gentoo :P
Out of curiosity does the gentoo package for netcat provide a /etc/init.d/ start script or are you starting it from the command line? I would think that the /etc/init.d/ should keep the server up after the user closes the connection.

Look for something in the /etc/init.d directory called netcat or netcatd, if it is there try running /etc/init.d/netcatd start (if it is netcatd). Through you may want to check if there is any settings you want to change in /etc/conf.d/ that relate to netcatd ( as a note those settings will only be there if there is a netcat service in /etc/init.d/ ... also if there is a netcat service, it won't nessecarly have a configuration file in /etc/conf.d/ )

Failing all that, a simple sh script would do it
netcat_loop.sh:

!/bin/sh
while [ 1 ]
do
command for starting netcat
done


Ps. Don't for chmod +x the script file before trying to run it or you will get an permission denined when you try to run it with ./netcat_loop.sh

Share this post


Link to post
Share on other sites
Thanks for your help. There's no netcatd, or the like, in init.d unfortunately. However, that gave me an idea. I'm attempting to set it up as an xinetd service. I doubt that it'll work, but I figure its worth a shot. I'm just not sure how a netcat service, running in the background, would share the console with the local shell. If it fails I'll probably just go with the script.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!