[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Brother, can you spare a paradigm



Hmmm,
Sat down last night and tried to open a socket to a remote
machine. ( I am using the 68k perl tool+freePPP+OT 1.1.1).

Not have a "fork" presents some difficulties :). Basically I
decided to send a "GET /<cr><lf> to some machines running web stuff
and grab the home page.  

The code looked something like this:
$iaddr=inet_aton($remote);
$paddr=sockaddr_in($port,$iaddr);
$proto=getprotobyname('tcp');
socket(SOCK,PF_INET,SOCK_STREAM,$proto) or die "socket: $!";
connect(SOCK,$paddr) or die "connect: $!";
select(SOCK); $|=1; select(STDOUT);

#print "-->"; $line=<STDIN>; $line = $line ."\n";
$line="GET /\n\012";
print SOCK $line;
$i=1;
while($line=<SOCK>) {
  print $i++, $line, "\n";
}
close(SOCK);

Much to my surprise I only got back 1 long line, it looks like
all of the <cr>'s where eaten , there was an "empty" box where
the lines where supposed to end.(I assume it was the line feed.)
Telneting to the port with a terminal program with "show control
characters" enabled showed that each line was terminated with a
<cr><lf> pair.

Does this make any sense? Does command buffering ($|=1) make sense
in the Mac environment.

Does anyone out there have any MacPerl socket code that talks to a
Unix Box.

Would "threads" be a way that MacPerl could give an illusion of multithreading?
(I thought I read that the MacOS now contained a thread package...

--Jerry
  levan@eagle.eku.edu