server.pl 676 B

1234567891011121314151617181920212223242526272829303132
  1. require ESL;
  2. use IO::Socket::INET;
  3. my $ip = "127.0.0.1";
  4. my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8040', Proto => 'tcp', Listen => 1, Reuse => 1 );
  5. die "Could not create socket: $!\n" unless $sock;
  6. for(;;) {
  7. my $new_sock = $sock->accept();
  8. my $pid = fork();
  9. if ($pid) {
  10. close($new_sock);
  11. next;
  12. }
  13. my $host = $new_sock->sockhost();
  14. my $fd = fileno($new_sock);
  15. my $con = new ESL::ESLconnection($fd);
  16. my $info = $con->getInfo();
  17. print $info->serialize();
  18. my $uuid = $info->getHeader("unique-id");
  19. $con->execute("answer", "", $uuid);
  20. $con->execute("playback", "/ram/swimp.raw", $uuid);
  21. close($new_sock);
  22. }