Sorry, this is a long one because there are so many pieces involved. I'm a relative newbie on some things mentioned below, but I think I've done the relevant research. I have a Perl script running on MacPerl on a mac 7300/180 PPC, and I have a Java applet running on a (plain) Pentium PC (inside the Applet viewer in Symantec Visual Cafe Web Edition 2.0). The Java applet opens a ServerSocket, and the MacPerl script opens a regular socket to connect. I know this seems backwards but I believe I have good reason to do it this way (if you really want to know reply and I'll admit why...). The jist of this message is that the socket connection seems to be made but the socket-reader in Java never returns. Details as follows: The two computers are connected via an ethernet hub (NetGear 4-port if it matters). I've set the IP addresses manually as follows: Mac: OS 8.5.1 IP address: 192.168.0.3 subnet mask: 255.255.255.0 MacPerl 5.2.0r4 patch level 5.004 PC: Windows 95 (4.00.950a) IP address: 192.168.0.6 subnet mask: 255.255.255.0 DNS: disabled java*.dll version 4.79.2435 The snippets below start with the MacPerl source (this is the entire source), and the generated output ($ENV{'REMOTE_ADDR'}, as you can see from the output, is 192.168.0.6 -- the IP address of the PC). The output suggests that the script opens a socket and successfully connects (inside ...::INET->new()), and then sends with no errors. As I understand it, $client->autoflush(1) [ which I've also seen in documentation as $client->autoflush() and $client->autoflush ] should take care of buffering -- also that fact that I output 2800 characters which should be more than a buffer's worth? Below the MacPerl output I include the snippet of Java source (I'm not including the entire file which is much larger, but this snippet should run as is inside most applets). This follows the recipes in just about every book I can find on how to do this. As you can see from the Java console output, the socket connection seems to be made, with the correct Mac information showing; however, it never comes back from any read() -- even the 1-char InputStream.read(). Any help would be greatly appreciated. I've searched in lots of Web FAQs and newsgroups but haven't seen this particular problem. Thanks, Rudi Sherry --------------------------- Relevant (?) Notes ------------------------- Note: I have a local network with a gateway and a soft router (that doesn't implement DHCP, which is why the IP addresses are hard coded). It does NAT with port translation; but since I get the same results when I turn off the gateway machine and have only the above machines connected via the hub, I don't think the gateway's the problem. Note: in the MacPerl output, 'sockdomain()' is 2 -- I believe that's PF_INET which is defined as AF_INET, but I'm not sure. Note: in the ServerSocket output from Java you can see the hostname "rudipc". This is the name of my PC in the Network control panel. Also notice the double "192.168.0.3" in the next line, which indicates a missing hostname from the Mac. I don't think either of these is relevant (famous last words). If I have the gateway on and connected to my ISP, instead of "rudipc" I see "rx-rs.rahul.net" but all the other symptoms are identical. Note: In MacPerl, after the call to INET->new(), sometimes $! is "Operation not supported on socket", but the socket is defined and all other symptoms are identical to when there is no error returned from $!. Does this indicate something amiss, even if it happens rarely? Note: I had one version where I output $! and $@ and both were blank. Note: There is some commented-out Java code that turned the InputStreamReader into a BufferedReader. It acts exactly the same way; ssIn.readLine() never returns. Note: In the Java code, the 'catch' clause is never executed (I had a breakpoint and forgot to put a println, but the breakpoint never hits). ---------- Perl source for MacPerl script running on Mac ------------- use IO::Socket; # $ENV{'REMOTE_ADDR'} is "192.168.0.6" my $client; $!= ""; print( "About to open socket to " . $ENV{'REMOTE_ADDR'} . ":5993\n" ); $client = IO::Socket::INET->new( PeerAdd => $ENV{'REMOTE_ADDR'}, PeerPort => 5993, Proto => "tcp", Type => SOCK_STREAM ); print( "errors: $!\n" ); print( "Just opened socket...\n" ); if ( defined $client ) { print( "INET->new() returned a real client:\n" ); print( " sockdomain:" . $client->sockdomain() . "\n" ); print( " sockport: " . $client->sockport() . "\n" ); print( " sockhost: " . $client->sockhost() . "\n" ); print( " peerport: " . $client->peerport() . "\n" ); print( " peerhost: " . $client->peerhost() . "\n" ); $client->autoflush(1); my $i; for ( $i = 0; $i < 100; $i++ ) { my $bytes = $client->send( "Hello from perl to the PC!\r\n" ); print( "sent $bytes bytes; error: $!\n" ); } $client->autoflush(1); $client->close; } else { print( "INET->new() returned null\n" ); } print( "Done\n" ); ---------- MacPerl output -------------------------------------------- About to open socket to 192.168.0.6:5993 errors: Just opened socket... INET->new() returned a real client: sockdomain:2 sockport: 2075 sockhost: 192.168.0.3 peerport: 5993 peerhost: 192.168.0.6 sent 28 bytes; error: sent 28 bytes; error: sent 28 bytes; error: . <snip> . sent 28 bytes; error: sent 28 bytes; error: sent 28 bytes; error: sent 28 bytes; error: Done ---------- Java source for Applet running on PC ---------------------- ServerSocket ss = null; try { ss = new ServerSocket( 5993, 50, InetAddress.getLocalHost() ); System.out.println( "Serversocket: " + ss.toString() ); Socket s = ss.accept(); System.out.println( "Serversocket accepted: " + s.toString() ); //BufferedReader ssIn = new BufferedReader( new InputStreamReader( s.getInputStream() ) ); InputStreamReader ssIn = new InputStreamReader( s.getInputStream() ); System.out.println( "About to read..." ); while ( true ) { //String line = ssIn.readLine(); //System.out.print( line ); int ch = ssIn.read(); System.out.print( ch ); } } catch ( IOException e ) { if ( ss != null ) try { ss.close(); } catch ( IOException e2 ) {} } ---------- Java Console (System.out) contents ------------------------ Serversocket: ServerSocket[addr=rudipc/192.168.0.6,port=0,localport=5993] Serversocket accepted: Socket[addr=192.168.0.3/192.168.0.3,port=2075,localport=5993] About to read... ---------- end of Java console: never comes back from ssIn.read(). --- (David) Rudi Sherry rudi_sherry@loftsoft.com San Jose, CA USA "We should all be tolerant of the foibles of age; with luck, we will achieve them ourselves." ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org