[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Help in writing a C program as a service deamon

Posted on 2004-10-26
Medium Priority
Last Modified: 2011-09-20
I want to write a deamon program that will create a random string and send it to its adjecent PC in a LAN?
First i want to know is that possible to send to neighbour PC? Is that require me to know its IP address?
I want to execute this program periodicaaly by 5 minutes and deamon will also store it in a file say /misc/text.txt file
 And i want to make it standard service deamon on redhat Linux 9 PC.
how to do it?

Question by:pancoder
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 12419425
Hi pancoder,
If you want to write your data in a file, I suggest you use NFS for that.
Export the target directory on your target PC, then mount it from the random-generating PC using NFS.
You can write directly to the file.



Author Comment

ID: 12419460
hi stefan73,
              No i dont want it. i want it through only C socket programs. cause file to be written replaces each random string after its updation to it occurs.

Expert Comment

ID: 12420133
Short answer: You send to the broadcast address.

Better Answer: Go get the Stevens book on Unix Network programming.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12429167
hello EinarTh,
              No i want to send only to neighbour by my pc by automatically detecting its ip address. how to detect ip address of neighbour pc. i dont want to send to every pc in LAN
LVL 12

Accepted Solution

stefan73 earned 150 total points
ID: 12431469
There's no simple way to know who your neighbour is. A "physical" neighbour isn't necessarily a logical one.
You could write its IP address into /etc/hosts, though. Then you can name it specifically.

Expert Comment

ID: 12465822
Maybe I'm reaching, but is this an attempt to secure the machine (so that access to the source PC & the random string is required to access the target PC)?

If so, you might want to look into SSH/PGP and or Kerberos -- it's likely it will fix the problem and avoid the problem of requiring you encrypt the random string over your socket to avoid packet snooping.

If not, can you be more explicit about what you are trying to do, and about what you mean by "neighbor pc"?  As Stefan73 said, there's usually no network information about the physical location -- do you already know the machine's name, and can it be found by DNS -- can you "ping" it?


Expert Comment

ID: 12520399
Answere to your Comment
 " No i want to send only to neighbour by my pc by automatically detecting its ip address. how to detect ip address of neighbour pc. i dont want to send to every pc in LAN"

Assumming you are connected to Ethernet network there is no way to define your neighbor's PC because its a broadcast media
Who is  A's neighbor B or C?
 ---                  ----
| A |               | B |
 ---                  ----
   |                    |
        | C |
You have to specify either the IP address or destination machine name . In later case the name should able to resolve to IP through /etc/hosts or DNS  

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question