Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I had much success using Net::Telnet to connect to a socket on a mainframe that delivered messages. Now that the mainframe had an upgrade and it seems to be sending EBCDIC rather than ascii. The mainframe people can't back out the change or figure out how to make the data be ascii again. I tried to adjust the Net::Telnet script to use a call to ebcdic2asciii found in Convert::EBCDIC. Of course nothing comes out or I wouldn't be writing. If I just telnet to the socket, I do see characters, weird ones of course. I assume I might be better off using IO:Socket::INET, but I am not sure how to make sure I stay connected unless the remote socket dies and how to tell I have 'enough' data that I can use ebcdic2ascii on. I simply want to print the incoming data to the screen. Here is telnet output, probably not useful, just showing there IS something.
Escape character is '^]'. cla;ccc}Q&P !cmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€cc +mcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€ccmcz«¦¢º€¡¦¢€c^] telnet> quit
Here is my basic attempt, which connects but doesn't print anything.
#!/usr/bin/perl use IO::Socket::INET; use Convert::EBCDIC; my ($socket,$client_socket); $socket = new IO::Socket::INET ( PeerHost => '', PeerPort => '6106', Proto => 'tcp', ) or die "ERROR in Socket Creation : $!\n"; print "TCP Connection Success.\n"; # read the socket data sent by server. $data = <$socket>; print "Received from Server : $data\n"; $data = ebcdic2ascii($data); print "Received from Server after : $data\n"; sleep (10); $socket->close();
Any ideas of what to try ? Thanks

In reply to Net::Telnet to IO::Socket::INET by sans-clue

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (6)
    As of 2018-03-19 16:57 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (244 votes). Check out past polls.