I have a Client-Server Perl program. I want to send a message stored in an array to the server.
Server code:
use IO::Socket::INET;
# Creating a a new socket
$socket=new IO::Socket::INET->new(LocalPort=>5000,Proto=>'udp');
print "\nUDPServer Waiting for client on port 5000";
while(1)
{
$socket->recv($recieved_data,1024);
$peer_address = $socket->peerhost();
$peer_port = $socket->peerport();
print "\n($peer_address , $peer_port) said : $recieved_data";
}
Client code::
use IO::Socket::INET;
# Create a new socket
$socket=new IO::Socket::INET->new(PeerAddr=>'127.0.0.1',PeerPort=>5000,Proto=>'udp');
@message_array = ("message", 120, "sample");
$socket->send(@message_array);
In server side I changed like,
$socket->recv(@recieved_data,1024);
But I am getting an error like this,
UDPServer Waiting for client on port 5000usage: $sock->recv(BUF, LEN [, FLAGS]) at udp_server.pl line 17
How to send an array and getting it printed or displayed in the server side.?