From: "Greg Aiken" <gai...@visioninfosoft.com> > I have a simple 10 line ascii text file: > > > line1CRLF > line2CRLF > . > line10CRLF > > where CRLF is really two bytes (hex 0d)(hex0a). > > I use IO::Socket as basis for a client program. > my program opens the above referenced file (for read), then reads each line > of the file, then sends each record read out through the socket. > at the same time, as I read the lines, I write them to a local log file. > the point of this exercise is to see why the data sent through the socket > DOES NOT MATCH the data sent to the local log file. > in the local log file, the written file size exactly matches the file size > of the originally read file. all bytes are identically preserved, to > include each CRLF byte pair. > > however, I use 'wireshark' to monitor the client/server communication here > and it is able to capture all tcp data being sent through my used port > number. wireshark then can save to disk the captured data packet. I > discovered that something here seems to be amiss regarding the CRLF byte > pair. 'wireshark' captured transmitted data reveals that only the LF byte > was being sent!!!!! somehow the CR byte does NOT get transmitted.
See perldoc -f binmode The CRLF->LF conversion happens when you read the file and since you opened the logfile in text mode the reverse LF->CRLF conversion happens as you write to the logfile. But sockets do not do this. binmode() both the file you read and the logfile and see. Jenda P.S.:This conversion happens only under operating systems that use the CRLF line ends. Thus your script would work find under Unix and break only once you/someone attempt to port it to Windows. ===== je...@krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs