I can write binary to a socket that successfully gets processed by the server. When the server replies, again in binary, my client hangs. I tried using echo to debugg but again the same issue (works fine with ASCII). Below is part of the code:
#!/opt/perl5/bin/perl use strict; use Socket; my $messageCounter = 0; my $message; my $reply; my $length; my $protocol = getprotobyname('tcp'); my $socketCreated; my $remoteHost = "XXXXXX"; my $packed_ip; my $remotePort = XXXX; my $portAddress; #BINARY OUTPUT FILE DEBUGGING ONLY my $binfilename = "BINARY_OUTPUT_FILE"; my $open_binName = sprintf(">%s", $binfilename); open(BIN_FILE, $open_binName) || die "can't open BIN_FILE: $!"; #Open Socket $socketCreated =socket(SocketHandle,PF_INET,SOCK_STREAM ,$protocol); $packed_ip = inet_aton($remoteHost); $portAddress = sockaddr_in($remotePort, $packed_ip); #Open Connection connect(SocketHandle, $portAddress) || die print "Could not Establish +a Connection\n"; print "Connection Successfully Established\n"; #enable buffering select((select(SocketHandle), $| = 1)[0]); $messageCounter++; $message = DCPLogin($messageCounter); # returns the binary string print SocketHandle $message; #hangs here while($length=sysread(SocketHandle, $reply, 1024)){ print BIN_FILE $reply; }#end while close(BIN_FILE) || die "couldn't close BIN_FILE: $!"; #debuggin +g only closeConn(); #function that closes the connection

In reply to reading binary from a socket by philiotis

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.