Perl send() UDP packet to multiple active clients -


i implementing perl based udp server/client model. socket functions recv() , send() used server/client communication. seems send() takes return address recv() call , can server respond client sent initial request. however, i'm looking server send data active clients instead of source client. if peer_address , peer_port each active client known, how use perl send() route packets specific clients? attempts:

foreach (@active_clients) {   #$_->{peer_socket}->send($data);   #$socket->send($_->{peer_socket}, $data, 0, $_->{peer_addr});   #send($_->{peer_socket}, $data, 0, $_->{peer_addr});   $socket->send($data) #echos source client } 

perldoc send briefly describes parameter passing. have attempted adopt , result either 1) client receives socket glob object or 2) packet never received or 3) error thrown. examples of how use send() route known clients appreciated.

yes, store addresses place , answer on them:

# receiving packets while (my $a = recv($sock, $buf, 8192, 0)) {     print "received $buf\n";     push @addrs, $a;     # exit @ point }  # send answers $a (@addrs) {     send($sock, "ok", 0, $a); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -