LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2005, 07:52 PM   #1
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
Creating socket programs as daemon


Hello,
I have UDP socket programs. I want to run server socket on one machine and client socket on another and viceversa.
How can i create a flexibility at each system so that it will not only listen from client socket but will also communicate to another server socket.
For that i think it require me to make both programs daemon so that they will run as backgroung hidden process.
How to do that on redhat linux 9 machnes with i386 arch?
 
Old 03-03-2005, 04:53 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: Creating socket programs as daemon

Quote:
Originally posted by cranium2004
How can i create a flexibility at each system so that it will not only listen from client socket but will also communicate to another server socket.
You can just open more than one socket, and use the select() function to have your program do nothing (sleep) until there's some activity on one of the sockets. Using select() is non-trivial, but there's some good documentation in it:
man 2 select # regular man page
man 2 select_tut # extra, tutorial man page.

Quote:
For that i think it require me to make both programs daemon so that they will run as backgroung hidden process.
How to do that on redhat linux 9 machnes with i386 arch?
Running as a daemon is not required to be listening on more-than-one socket at a time. But to make a program run as a daemon, just #include <unistd.h> and call daemon(0,0).
 
Old 03-04-2005, 04:42 AM   #3
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
So that mean i have to use select in my Server socket program so that same udpserver.c and udpclient.c sourcecode compiled binary files be placed on all machines in LAN and all those machines can communiate thru those same client server programs right???
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating simple sh daemon bobbens Programming 6 06-01-2005 11:10 AM
creating server socket program to handle multiple client at same time cranium2004 Programming 2 03-14-2005 10:58 AM
how to run programs through a socket jostre11 Programming 6 11-02-2004 03:53 PM
daemon to count number of times programs are being run dizzutch Linux - Software 0 10-27-2004 08:41 AM
samba daemon socket error richard22 Linux - Networking 7 08-21-2003 06:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:52 AM.

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