=encoding utf8

=head1 NAME

IOMux::Service::TCP - TCP (socket) based service

=head1 INHERITANCE

 IOMux::Service::TCP
   is an IOMux::Handler::Service
   is an IOMux::Handler

=head1 SYNOPSIS

  my $service = IOMux::Service::TCP->new
    ( # capitalized params are passed to the socket constructor
      Host   => 'localhost:8080'
    , Listen => 3

      # object to initialize when new connection arrives
    , conn_type => $conn_handler_class  # extends IOMux::Net::TCP
    , conn_opts => \@conn_handler_init_params
    );

=head1 DESCRIPTION

Accept TCP connections. When a connection arrives, it will get
handled by a new object which gets added to the multiplexer as
well.

Extends L<"DESCRIPTION" in IOMux::Handler::Service|IOMux::Handler::Service/"DESCRIPTION">.
 
=head1 METHODS

Extends L<"METHODS" in IOMux::Handler::Service|IOMux::Handler::Service/"METHODS">.
 
=head2 Constructors

Extends L<"Constructors" in IOMux::Handler::Service|IOMux::Handler::Service/"Constructors">.
 
=over 4

=item IOMux::Service::TCP-E<gt>B<new>(%options)

 -Option   --Defined in     --Default
  conn_opts                   []
  conn_type                   <required>
  fh         IOMux::Handler   <required>
  hostname                    <sockhost:sockport>
  name       IOMux::Handler   'listen tcp $host:$port'
  socket                      <created from capitalized parameters>

=over 2

=item conn_opts => ARRAY

Pass some extra options when objects of C<conn_type> are created, passed
as list of pairs.

=item conn_type => CLASS|CODE

The CLASS (package name) of client to be created for each new contact.
This CLASS must extend  L<IOMux::Net::TCP|IOMux::Net::TCP>. You may also provide a
CODE reference which will be called with the socket leading to the client.

=item fh => FILEHANDLE

=item hostname => URI

How this socket gan be addressed from remote, for instance as
virtual host for HTTP.

=item name => STRING

=item socket => IO::Socket::INET object

=back

=item IOMux::Service::TCP-E<gt>B<open>($mode, $what, %options)

Inherited, see L<IOMux::Handler/"Constructors">

=back

=head2 Accessors

Extends L<"Accessors" in IOMux::Handler::Service|IOMux::Handler::Service/"Accessors">.
 
=over 4

=item $obj-E<gt>B<clientType>()

=item $obj-E<gt>B<fh>()

Inherited, see L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<fileno>()

Inherited, see L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<hostname>()

=item $obj-E<gt>B<mux>()

Inherited, see L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<name>()

Inherited, see L<IOMux::Handler/"Accessors">

=item $obj-E<gt>B<socket>()

=item $obj-E<gt>B<usesSSL>()

Inherited, see L<IOMux::Handler/"Accessors">

=back

=head2 User interface

Extends L<"User interface" in IOMux::Handler::Service|IOMux::Handler::Service/"User interface">.
 
=head2 Multiplexer

Extends L<"Multiplexer" in IOMux::Handler::Service|IOMux::Handler::Service/"Multiplexer">.
 
=head3 Connection

Extends L<"Connection" in IOMux::Handler::Service|IOMux::Handler::Service/"Connection">.
 
=over 4

=item $obj-E<gt>B<muxInit>( $mux, [$handler] )

Inherited, see L<IOMux::Handler/"Connection">

=item $obj-E<gt>B<muxRemove>()

Inherited, see L<IOMux::Handler/"Connection">

=item $obj-E<gt>B<muxTimeout>()

Inherited, see L<IOMux::Handler/"Connection">

=back

=head3 Reading

Extends L<"Reading" in IOMux::Handler::Service|IOMux::Handler::Service/"Reading">.
 
=over 4

=item $obj-E<gt>B<muxExceptFlagged>($fileno)

Inherited, see L<IOMux::Handler/"Reading">

=item $obj-E<gt>B<muxReadFlagged>()

=back

=head3 Writing

Extends L<"Writing" in IOMux::Handler::Service|IOMux::Handler::Service/"Writing">.
 
=over 4

=item $obj-E<gt>B<muxWriteFlagged>($fileno)

Inherited, see L<IOMux::Handler/"Writing">

=back

=head3 Service

Extends L<"Service" in IOMux::Handler::Service|IOMux::Handler::Service/"Service">.
 
=over 4

=item $obj-E<gt>B<muxConnection>($client)

Inherited, see L<IOMux::Handler::Service/"Service">

=back

=head2 Helpers

Extends L<"Helpers" in IOMux::Handler::Service|IOMux::Handler::Service/"Helpers">.
 
=over 4

=item $obj-E<gt>B<extractSocket>(HASH)

=item IOMux::Service::TCP-E<gt>B<extractSocket>(HASH)

Inherited, see L<IOMux::Handler/"Helpers">

=item $obj-E<gt>B<fdset>($state, $read, $write, $error)

Inherited, see L<IOMux::Handler/"Helpers">

=item $obj-E<gt>B<show>()

Inherited, see L<IOMux::Handler/"Helpers">

=back

=head1 DIAGNOSTICS

=over 4

=item Error: $pkg needs STREAM protocol socket

=item Error: a conn_type for incoming request is need by $name

=item Error: accept for socket $name failed

=back

=head1 SEE ALSO

This module is part of IOMux distribution version 1.01,
built on January 15, 2020. Website: F<http://perl.overmeer.net/CPAN>

=head1 LICENSE

Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>

