Path: utzoo!attcan!uunet!snorkelwacker!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!uvaarpa!mmdf From: cdp@hertz.njit.edu (Chris Peckham) Newsgroups: comp.lang.perl Subject: Help with sockets and lpd Message-ID: <1990Jun7.225250.29252@uvaarpa.Virginia.EDU> Date: 7 Jun 90 22:52:50 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: cdp@hertz.njit.edu Organization: The Internet Lines: 46 I am attempting to connect to the printer daemon which is on tcp port 515 using sockets. The system we are running is Ultrix-32 V3.1 (Rev. 9) System #7. The problem is the same even when I vary the $them variable below. The message that comes back to me is: 'Malformed from address' If I use the same structure to address the ftp port or telnet port, I get the header info of that process back. The lpd should respond with a 0 or something telling me ok (or is that my misunderstanding :-) ). Any help would be greatly appreciated. Chris Peckham, Systems Programmer New Jersey Institute of Technology cdp@hertz.njit.edu ***************************************************************************** #!/usr/bin/perl do 'socket.pl' || die "socket.pl"; # Get sockets info chop($hostname = `hostname`); $them=$hostname; # Can change later $sockaddr = 'S n a4 x8'; # Set TEMPLATE for pack # Get names and such ($name, $aliases, $proto) = getprotobyname('tcp'); ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname); ($name, $aliases, $port) = getservbyname('printer','tcp'); ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them); $client=pack($sockaddr,&AF_INET,0,$thisaddr); $server=pack($sockaddr,&AF_INET,$port,$thataddr); socket(S,&AF_INET,&SOCK_STREAM, $proto) || die "socket: $!"; bind(S, $client) || die "bind: $!"; connect(S, $server) || die "connect: $!"; select(S); $| = 1 ; select(STDOUT); print S '\002lp\n'; read(S,$line,255); # Here is the trouble maker print $line; close S;