NAME

Net::HL7::Daemon

SYNOPSIS

my $d = new Net::HL7::Daemon( LocalPort => 12002, Listen => 5 );

DESCRIPTION

The Net::HL7::Daemon class provides a Daemon, roughly based on the well known HTTP::Daemon class. The daemon wraps IO::Socket::INET so that incoming connections are returned as Net::HL7::Daemon::Client objects. Other than that the Daemon class doesn't do all that much. However, this allows you to use the Daemon class as a base for more elaborate servers, like preforking or multi-threaded servers. See the Perl Cookbook for examples on this, and think Net::HL7::Daemon where you see IO::Socket.

METHODS

$d = new Net::HL7::Daemon()

Create a new instance of the Daemon class. Arguments are the same as for the IO::Socket::INET.

$c = $d->accept([$pkg])

This method is the same as IO::Socket::accept but returns an Net::HL7::Daemon::Client reference. It returns undef if you specify a timeout and no connection is made within that time. In a scalar context the returned value will be a reference to a object of the Net::HL7::Daemon::Client class which is another IO::Socket::INET subclass. In a list context a two-element array is returned containing the new Net::HL7::Daemon::Client reference and the peer address; the list will be empty upon failure.

$d->getHost()

Returns the host where this daemon can be reached.

$d->getPort()

Returns the port on which this daemon is listening.

Net::HL7::Daemon::Client

DESCRIPTION

The Net::HL7::Daemon::Client is also a IO::Socket::INET subclass. Instances of this class are returned by the accept() method of Net::HL7::Daemon.

METHODS

$c->getRequest()

Read data from the socket and turn it into an Net::HL7::Request object which is then returned. It returns undef if reading of the request fails. If it fails, then the Net::HL7::Daemon::Client object ($c) should be discarded, and you should not call this method again. Potentially, a HL7 client can receive more than one message. So discard the client only when there's no more requests pending, or the delivering service might experience timeouts.

$c->sendAck([$res])

Write a Net::HL7::Messages::ACK message to the client as a response, to signal success. You may provide your own Net::HL7::Response, but it is better to rely on the ACK that is generated internally.

$c->sendNack($req, [$msg], [$res])

Write a Net::HL7::Messages::ACK message to the client as a response, with the Acknowledge Code (MSA(1)) set to CE or AE, depending on the original request, to signal an error.

$c->sendResponse($res)

Write a Net::HL7::Reponse object to the client as a response. This can hold an arbitrary HL7 message.

RFC 2068

IO::Socket::INET

COPYRIGHT

Copyright 2003, D.A.Dokter

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 123:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content

Around line 225:

'=item' outside of any '=over'

Around line 240:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content

Around line 247:

You forgot a '=back' before '=head1'