ePages 7.21.0 - DE_EPAGES/Core/API/Object/UDPMultiClient.pm

Package DE_EPAGES::Core::API::Object::UDPMultiClient

UDP client class for multiplexed servers

Functions

new
numConnections
receive
receiveAll
send
sendReceive
sendReceiveAll
useAutoflush

new

Creates a new UDPMultiClient object.

Syntax
$UDPMultiClient = DE_EPAGES::Core::API::Object::UDPMultiClient->new($aHosts);
Example
my $UDPMultiClient = DE_EPAGES::Core::API::Object::UDPMultiClient->new([['servername', 10043]]);
$UDPMultiClient->send('Hello');
Input
$aHostAddr (ref.array.array.string)
array of host names or IP addresses, and ports
$Autoflush (boolean)
automatically discard received data before sending any new data (default true)
Return
$UDPMultiClient (DE_EPAGES::Core::API::Object::UDPMultiClient)
UDPMultiClient object

numConnections

Returns the number of active socket connections for this client

Syntax
$UDPClient->numConnections;
Return
$NumConnections (int)
number of active socket connections

receive

Receives UDP messages

Syntax
my $Response = $UDPMultiClient->receive( $TimeoutSec, $MaxLength );
Input
$TimeoutSec (float)
maximum time to wait for data in seconds (default 1.0)
$MaxLength (integer)
maximum length of the received data (default 1024)
Return
$Response (string)
received data or undef if none was received

receiveAll

Receives UDP messages from all clients

Syntax
my $Responses = $UDPMultiClient->receiveAll( $TimeoutSec, $MaxLength );
Input
$TimeoutSec (float)
maximum time to wait for data in seconds (default 1.0)
$MaxLength (integer)
maximum length of the received data (default 1024)
Return
$Responses (ref.array.string)
received data or undef if none was received

send

Sends an UDP message containing $Data.

Syntax
$UDPClient->send( $Data );
Input
$Data (string)
bytes to send

sendReceive

Sends an UDP message containing $Data, then waits for and returns a response

Syntax
my $Response = $UDPMultiClient->sendReceive( $Data, $TimeoutSec, $MaxLength );
Input
$Data (string)
bytes to send
$TimeoutSec (float)
maximum time to wait for a response in seconds (default 1.0)
$MaxLength (integer)
maximum length of the received data (default 1024)
Return
$Response (string)
received data or undef if none was received

sendReceiveAll

Sends an UDP message containing $Data, then waits for and returns all responses

Syntax
my $Responses = $UDPMultiClient->sendReceiveAll( $Data, $TimeoutSec, $MaxLength );
Input
$Data (string)
bytes to send
$TimeoutSec (float)
maximum time to wait for a response in seconds (default 1.0)
$MaxLength (integer)
maximum length of the received data (default 1024)
Return
$Responses (ref.array.string)
received data or undef if none was received

useAutoflush

Sets the autoflush flag of the client. Enabling autoflush discards all data still present on the receiving ends of the underlying sockets before sending a new request. This data is usually redundant and unwanted. Disable autoflush if you want to receive all responses (even the redundant ones) from all connected servers. We need this when using UDPMultiClient in conjunction with DE_EPAGES::WebInterface::API::SequenceProtocol.

Syntax
my $Autoflush = $UDPMultiClient->useAutoflush();
$UDPMultiClient->useAutoflush(0);
Input
$Flag (boolean)
1 to enable, 0 to disable autoflush
Return
$Autoflush (boolean)
1 if autoflush is enabled, otherwise 0