From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 12 March 2009 23:33
To: perl-win32-users@listserv.activestate.com
Subject: IO::Socket (client program sends simple text file containing
CRLFnewlines)

> 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.
>  
> this has been preventing my client program from being able to work
properly with the backend IIS web server.
>  
> can anyone elaborate as to why this might be happening?  ive reviewed
the IO::socket documentation and do not 
> see any mention of this behaviour.
>  
> im pretty puzzled...

Unfortunately you don't provide any code, so I shall have to guess a
bit.

Assuming that you are running in a win32 platform, your line endings
will be translated to "\n" (i.e. line feed) when they are read in,
unless you say different with binmode. What may not be obvious is that
sockets are opened in binary mode, so it will be the translated line
endings that are transmitted. The only reference to this feature that I
am aware of is in 'perldoc perlopentut', under Binary Files. If anyone
knows of a better reference, please shout.

It looks like you might want to binmode your input file handle. Or
possibly chomp your input lines, and explicitly add CRLF when you send
them to the socket.

HTH

-- 
Brian Raven 

-----------------------------------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy. Any unauthorised copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to