Comment 14 for bug 1061069

Revision history for this message
In , Johannes Meixner (jsmeix) wrote :

There is a typo in comment #9:
"Regarding comment #9" should read "Regarding comment #7".

Regarding sending CUPS Browsing info as UDP broadcast:

Sending CUPS Browsing info as UDP broadcast via bash fails (even as root):
-------------------------------------------------------------------------------
echo '2 3 ipp://PRINT.SERVER.IP.ADDRESS:631/printers/QUEUE-NAME "Location"
"Description" "Make and Model" lease-duration=300 job-sheets=none,none'
>/dev/udp/HOST:BROADCAST:IP:ADDRESS/631

-bash: connect: Permission denied
-bash: /dev/udp/HOST:BROADCAST:IP:ADDRESS/631: Permission denied
-------------------------------------------------------------------------------

I don't know how to set SO_BROADCAST (see "man 7 socket") via bash
so that I use this perl script (the $data assignment is one line):
--------------------------------------------------------------------------------
#!/usr/bin/perl

use strict;
use IO::Socket;

my $bcaddr = 'HOST:BROADCAST:IP:ADDRESS';
my $port = 631;
my $data = '2 3 ipp://PRINT.SERVER.IP.ADDRESS:631/printers/QUEUE-NAME "Location"
"Description" "Make and Model" lease-duration=300 job-sheets=none,none';

socket(sock, PF_INET, SOCK_DGRAM, getprotobyname("udp")) or die "socket:$@";
setsockopt(sock, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt:$@";
my $dest = sockaddr_in($port,inet_aton($bcaddr));

send(sock,$data,0,$dest) or die "send():$!";
--------------------------------------------------------------------------------