Agent::Transport - the Transportable Agent Perl module
use Agent::Transport;
# for receiving messages:
$tcp = new Agent::Transport(
Medium => 'TCP',
Address => '1.2.3.4:1234'
);
# for sending:
use Agent::Message;
$msg = new Agent::Message(
Medium => 'TCP',
Body => [ @body ],
Address => '1.2.3.4:1234'
);
$msg->send;
This package provides an interface to the TCP[/IP] transport medium for agent
developers to make use of.
- This package groks the following standard tcp/ip formats:
-
aaa.bbb.ccc.ddd:port
host.domain:port
- new( %args )
- If the Cycle argument is passed and if new() cannot capture
the port specified, it will cycle through port numbers until a free port
is found. If "new" is not passed an
Address at all, it assumes '127.0.0.1:24368', and sets Cycle
to 1.
This module contains all of the Agent::Transport standard methods. Some
non-standard features have also been introduced:
- $self->accept( %args )
- This method is analagous to the accept() function call and is
introduced to allow agent programmers to make full use of bi-directional
sockets. It simply opens an incoming connection and returns that object,
thus allowing you to use a single connection for multiple messages (see
"IO::Socket" for details).
Unfortunately, you'll have to design your own protocol.
Passing a 'From' argument as a referenced scalar, causes
accept() to put what it thinks the remote address is into
this variable.
- $self->alias()
- Returns $self->address() only. It should
really do hostname lookups.
- $self->recv( %args )
- Passing a 'From' argument as a referenced scalar, causes recv() to
put what it thinks the remote address is into this variable.
Otherwise, recv() functions as described in
Agent::Transport.
- send( %args )
- If you pass send() a 'KeepAlive' argument containing a
reference to a scalar, it will set this scalar to the remote
socket filehandle. This is meant to be used in conjunction with
accept(), and is useful if you would like to have an extended
conversation with the remote host.
This module only binds to a specified address. If you have multiple interface
addresses (ie: eth0 & eth1), and you want to listen on more than one, you
have to bind each seperately.
"Agent"
"Agent::Transport"
Steve Purkis <spurkis@engsoc.carleton.ca>
Copyright (c) 1998 Steve Purkis. All rights reserved. This program is free
software; you can redistribute it and/or modify it under the same terms as
Perl itself.
Various people from the perl5-agents mailing list.