Dear all I'm having difficulty in reading from a java socket in perl.
java code:**SERVER** int port=5551; ServerSocket ss=new ServerSocket(port); // System.out.println("Waiting for lient"); Socket s=ss.accept(); // System.out.println("Waiting for clienttttt"); BufferedReader br=new BufferedReader(new InputStreamReade +r(s.getInputStream())); DataOutputStream pw = new DataOutputStream(s.getOutputStr +eam()); //PrintWriter pw=new PrintWriter(new OutputStreamWriter(s +.getOutputStream())) ; String str=br.readLine(); int n=Integer.parseInt(str); int i; long f=1; System.out.println("Number sent by client: " + n); for(i = 2; i <= n; i++) f = f * i; System.out.println("Number sent to client: " + f +n); pw.writeLong(f); perl code ***CLIENT**** use threads::shared; 2 use IO::Socket; 3 use IO::Select; #[/RP001] 4 use IO::Handle; 5 chomp(my $hostname = `hostname`); 6 7 my $dmx_sock = new IO::Socket::INET( 8 PeerAddr => $hostname, 9 PeerPort => 5551, 10 Proto => 'tcp', 11 ); 12 $dmx_sock or print "err"; 13 print $dmx_sock "2"; 14 sleep(5); 15 my $buf; 16 read($dmx_sock, $buf,1); 17 18 my ($tag,$code,$len) = unpack 'L', $buf; 19 print "\$tag = '$tag'\n"; 20 print "\$code = '$code'\n"; 21 print "\$len = '$len'\n"; 22 read($socket, $buf, $len); 23 print "\$buf = '$buf'"; 24 25 26 27 #$dmx_sock->close; 28 print "<<<$buf>>>>"; ~
when I run the server program followed by client , java socket reads the input from perl socket but in perl I'm not able to receive data. can anyone suggest how to read from java socket in perl Hit me if I see to be less informative on this. thanking u in advance

In reply to reading data from java socket by ramprasadgk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.