LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-27-2006, 10:35 AM   #1
flobadob
LQ Newbie
 
Registered: Aug 2005
Posts: 10

Rep: Reputation: 0
Writing a server process


I am writing a process in C++ and Qt which will service a bunch of requests via tcp sockets. I notice that all the demons in linux can be switched on an off with standard start stop restart arguments. Where can I find information on modifying my application to conform to this start, stop, restart standard?
 
Old 10-27-2006, 10:38 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
You can view the existing "services" you have on your machine, they have a pretty simple switch inside the file which determines if you want to start, stop or restart the service. I think you'll be able to figure out (or even copy-paste) the structure by taking a look at the existing service scripts, so go ahead.
 
Old 10-27-2006, 10:52 AM   #3
flobadob
LQ Newbie
 
Registered: Aug 2005
Posts: 10

Original Poster
Rep: Reputation: 0
OK, thanks. I see they are all similar. I can copy and paste my own. Cheers.
 
Old 10-28-2006, 01:59 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Yes, there's usually a /etc/services or similar directory in which all of these files appear.

The usual command (varies for your distro) for starting, stopping and managing services is a command-file that you can actually read. (Just don't change anything.)

The /etc/inittab file is the magic reference list that starts everything off. (See: man init. Read about "runlevels.")

When you design your service, consider from the very beginning that you'd like to have it run as a non-privileged (non-root) user, and that it might be started by xinetd, which listens to ports and starts services on-demand.

By all means, study carefully the cornucopia of existing code. If you don't find exactly what you are looking for, you're sure to find something that's very close.
Quote:
Dictum ne agas - "do not do a thing already done."
Conservatum follicum - "the hair you save may be your own. (And you might wish to have it, someday.)"
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Request Data to Web Server lucky6969b Programming 1 12-20-2005 10:43 PM
Help with writing a small web server Diederick Programming 2 08-19-2005 07:46 PM
Linux HA and writing scripts to kill process sceadu Programming 0 07-28-2005 03:27 AM
writing a server status script thebored Linux - Software 2 07-22-2005 01:25 AM
writing to child process stdin avikosan Programming 2 11-11-2003 07:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration