|Think about Loose Coupling|
when i dump the binary code to .txt and change it to .jpeg image is not shown.
JFIF is the correct internal identifier for .jpg's; changing it to .JPG doesn't make any sense at all.
If your image tools aren't recognising the file format, it probably means that it is getting corrupted in some (other) way.
I suspect, based upon your (very limited) code snippet, that you are probably forgetting to binmode the socket you are reading from, and/or using readline (or <$fh>) to read from that socket, without having changed the input separator.
To get a proper answer, you'd need to show the full code -- or at the very least, the code where you open the socket and read from it -- but the full code would save you and us time.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.