Find the answer to your Linux question:
Results 1 to 6 of 6
Hi all First my apologies if this query has been covered elsewhere. I've performed a search and have been unable to find a solution to my problem. I need to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2006
    Posts
    6

    Question Creating a daemon


    Hi all

    First my apologies if this query has been covered elsewhere. I've performed a search and have been unable to find a solution to my problem.

    I need to create a daemon that listens on a set port, and processes a string sent to it from a server.

    So far the server program has been written that sends the string, but this is my first time at writing daemons, so I need some advice.

    I found a sample daemon here: http://www.linuxprofilm.com/articles...mon-howto.html

    What I need to know is what other files are required and how do I get it to process the string sent from the server?

    Any help would be most appreciated

    offworld21

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    A basic HOWTO on writing a daemon is available at:

    http://www.linuxprofilm.com/articles...mon-howto.html

  3. #3
    Just Joined!
    Join Date
    Sep 2006
    Posts
    6

    Wink ???

    Cabhan, thanks for the reply, but did you actually read my post??

    I actually reference the same HOWTO.

    The availability of a daemon's structure is not the issue here.

    What I need to know is:

    1. What other files are needed once the daemon is written
    2. If one of the files needed is a config file, what should it contain and how should it be written
    3. How to get the daemon to process the string received on the listening port
    4. Where to specify the port it listens on


    These are just the questions I can think of at the moment, but if anyone can shed any light, please do.

    Thanks again

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Ah, I saw your post (and the link), but I didn't think to compare the URLs .

    Anyway, how to receive the string, you basically need to listen on whatever port for the string to come to you (as you said). The glibc documentation discusses ports at:
    http://www.gnu.org/software/libc/man...rts.html#Ports

    Do you need a config file? I don't know. Is your daemon customizable and configurable? Then yes. You can choose your own format: XML is popular because it is easily parseable by both computers and people. In an app that I wrote, I use a format like:
    Code:
    ; Various Names
    Command
    Description
    Command
    Description
    ...
    Choose your own. The format that I came up with (I kind of took it from WINE) is very easy to write your own parser for, but for detailed config files can be very difficult to understand. Do what you will.

    Finally, as an example that ties all of the socket stuff together, look at:
    http://www.gnu.org/software/libc/man...l#Inet-Example

  6. #5
    Just Joined!
    Join Date
    Sep 2006
    Posts
    6

    Question Changing tack!

    Hi Cabhan

    Thanks for getting back to me, no worries on the link, its probably the best daemon link I've found!

    I'm now looking at using xinetd again, but changing from using my C program to using a shell script. What I need to know is how to parse the string sent from the server and process it with my shell script, using xinetd?

    I hope this makes sense

    Once again, thank you

  7. #6
    Just Joined!
    Join Date
    Sep 2006
    Posts
    6

    Question Nearly..

    Ok, I think I may have cracked it (being new to this hasn't helped!)

    The easiest way I can explain what I need to happen is this:

    The server sends an IP address to the client.
    The client receives this information and puts it into a text file.

    What is the easiest way to achieve this?

    Once again, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •