<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Perl socket-daemon example in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054905#M719137</link>
    <description>Hi! &lt;BR /&gt;I'm trying to make a small client-server /using INET-socket/ example on Perl. &lt;BR /&gt;Here it is: &lt;BR /&gt;#=======================&lt;BR /&gt;# Server &lt;BR /&gt;#======================= &lt;BR /&gt;use IO::Socket; &lt;BR /&gt;my $sock = new IO::Socket::INET ( &lt;BR /&gt;&lt;BR /&gt;LocalAddr =&amp;gt; 'servername.com', &lt;BR /&gt;LocalPort =&amp;gt; '7777', &lt;BR /&gt;Proto =&amp;gt; 'tcp', &lt;BR /&gt;Listen =&amp;gt; 1, &lt;BR /&gt;Reuse =&amp;gt; 1, &lt;BR /&gt;); &lt;BR /&gt;die "Could not create socket: $!\n" unless $sock; &lt;BR /&gt;my $new_sock = $sock-&amp;gt;accept(); &lt;BR /&gt;while(defined($Line = &amp;lt;$new_sock&amp;gt;)) { &lt;BR /&gt;print $Line; &lt;BR /&gt;} &lt;BR /&gt;close($sock); &lt;BR /&gt;&lt;BR /&gt;#=============================================# Client  &lt;BR /&gt;#============================================= &lt;BR /&gt;use IO::Socket; &lt;BR /&gt;my $sock = new IO::Socket::INET ( &lt;BR /&gt;PeerAddr =&amp;gt; 'servername.com', &lt;BR /&gt;PeerPort =&amp;gt; '7777', &lt;BR /&gt;Proto =&amp;gt; 'tcp', &lt;BR /&gt;); &lt;BR /&gt;die "Could not create socket: $!\n" unless $sock; &lt;BR /&gt;print $sock "Hi there!\n"; &lt;BR /&gt;$sock-&amp;gt;send("Hi again!\n"); &lt;BR /&gt;close($sock); &lt;BR /&gt;&lt;BR /&gt;It is working! Now I want to do the following: &lt;BR /&gt;&lt;BR /&gt;1. To make this server to work like a daemon. &lt;BR /&gt;I've tried with: &lt;BR /&gt;&lt;BR /&gt;    use Proc::Daemon; &lt;BR /&gt;    Proc::Daemon::Init(); &lt;BR /&gt;&lt;BR /&gt;This was working like daemon , but was damaging socket-part. &lt;BR /&gt;&lt;BR /&gt;2. To make this server to "fork" child process,which will execute row &lt;BR /&gt;"print $Line" itself and died after that. &lt;BR /&gt;Main proccess must remain live after this &lt;BR /&gt;action. &lt;BR /&gt;&lt;BR /&gt;Is anywhere a suitable modules and simple code for doing this? &lt;BR /&gt;Thank's in advance!A points-gift will be done!  Stan</description>
    <pubDate>Fri, 22 Aug 2003 12:33:53 GMT</pubDate>
    <dc:creator>Stanimir</dc:creator>
    <dc:date>2003-08-22T12:33:53Z</dc:date>
    <item>
      <title>Perl socket-daemon example</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054905#M719137</link>
      <description>Hi! &lt;BR /&gt;I'm trying to make a small client-server /using INET-socket/ example on Perl. &lt;BR /&gt;Here it is: &lt;BR /&gt;#=======================&lt;BR /&gt;# Server &lt;BR /&gt;#======================= &lt;BR /&gt;use IO::Socket; &lt;BR /&gt;my $sock = new IO::Socket::INET ( &lt;BR /&gt;&lt;BR /&gt;LocalAddr =&amp;gt; 'servername.com', &lt;BR /&gt;LocalPort =&amp;gt; '7777', &lt;BR /&gt;Proto =&amp;gt; 'tcp', &lt;BR /&gt;Listen =&amp;gt; 1, &lt;BR /&gt;Reuse =&amp;gt; 1, &lt;BR /&gt;); &lt;BR /&gt;die "Could not create socket: $!\n" unless $sock; &lt;BR /&gt;my $new_sock = $sock-&amp;gt;accept(); &lt;BR /&gt;while(defined($Line = &amp;lt;$new_sock&amp;gt;)) { &lt;BR /&gt;print $Line; &lt;BR /&gt;} &lt;BR /&gt;close($sock); &lt;BR /&gt;&lt;BR /&gt;#=============================================# Client  &lt;BR /&gt;#============================================= &lt;BR /&gt;use IO::Socket; &lt;BR /&gt;my $sock = new IO::Socket::INET ( &lt;BR /&gt;PeerAddr =&amp;gt; 'servername.com', &lt;BR /&gt;PeerPort =&amp;gt; '7777', &lt;BR /&gt;Proto =&amp;gt; 'tcp', &lt;BR /&gt;); &lt;BR /&gt;die "Could not create socket: $!\n" unless $sock; &lt;BR /&gt;print $sock "Hi there!\n"; &lt;BR /&gt;$sock-&amp;gt;send("Hi again!\n"); &lt;BR /&gt;close($sock); &lt;BR /&gt;&lt;BR /&gt;It is working! Now I want to do the following: &lt;BR /&gt;&lt;BR /&gt;1. To make this server to work like a daemon. &lt;BR /&gt;I've tried with: &lt;BR /&gt;&lt;BR /&gt;    use Proc::Daemon; &lt;BR /&gt;    Proc::Daemon::Init(); &lt;BR /&gt;&lt;BR /&gt;This was working like daemon , but was damaging socket-part. &lt;BR /&gt;&lt;BR /&gt;2. To make this server to "fork" child process,which will execute row &lt;BR /&gt;"print $Line" itself and died after that. &lt;BR /&gt;Main proccess must remain live after this &lt;BR /&gt;action. &lt;BR /&gt;&lt;BR /&gt;Is anywhere a suitable modules and simple code for doing this? &lt;BR /&gt;Thank's in advance!A points-gift will be done!  Stan</description>
      <pubDate>Fri, 22 Aug 2003 12:33:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054905#M719137</guid>
      <dc:creator>Stanimir</dc:creator>
      <dc:date>2003-08-22T12:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Perl socket-daemon example</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054906#M719138</link>
      <description>Here's a close example of something I did for a SysAdmin article to setup multi-platform semaphores using Perl sockets.&lt;BR /&gt;&lt;BR /&gt;The essential steps to daemonizing a process are:&lt;BR /&gt;1) fork() -- parent generally just exits the child does the work.&lt;BR /&gt;2) setsid() - detaches controlling terminal&lt;BR /&gt;3) chdir("/") - so that no filesystems are busy; you don't want to make it difficult for admins to umount a filesystem.&lt;BR /&gt;4) setup the signal handlers (e.g. ignore SIGINT, SIGHUP, possibly put in a handler to shutdown when SIGTERM is received.&lt;BR /&gt;&lt;BR /&gt;All of this is illustrated in the attachment plus setting up bidirectional sockets.&lt;BR /&gt;&lt;BR /&gt;The is server.pl.</description>
      <pubDate>Fri, 22 Aug 2003 13:02:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054906#M719138</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-08-22T13:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perl socket-daemon example</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054907#M719139</link>
      <description>Here's the client piece that talks to the server using sockets.&lt;BR /&gt;&lt;BR /&gt;This is client.pl.&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2003 13:03:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054907#M719139</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-08-22T13:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Perl socket-daemon example</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054908#M719140</link>
      <description>Thanks, Mr. Stephenson!&lt;BR /&gt;I must look over your scripts in details.&lt;BR /&gt;It seems you are an experienced developer&lt;BR /&gt;on Perl. I thing I know the main principles, used in "daemonization" of program. And I&lt;BR /&gt;have seen it in module: Daemon.pm.&lt;BR /&gt;But when I'm trying to apply this&lt;BR /&gt;module /look at my 1. above/, I'm doing&lt;BR /&gt;my program to work like daemon, but&lt;BR /&gt;the server is stopping to receive messages&lt;BR /&gt;for client. May I ask you kindly to &lt;BR /&gt;look over this module? What is the problem?&lt;BR /&gt;I'm attaching it.&lt;BR /&gt;Thank you very much, Stan &lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2003 13:27:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-socket-daemon-example/m-p/3054908#M719140</guid>
      <dc:creator>Stanimir</dc:creator>
      <dc:date>2003-08-22T13:27:31Z</dc:date>
    </item>
  </channel>
</rss>

