LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack 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
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
Senior Member
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 3,682

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 03:40 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration