Are you connecting to a Unix server from a windoze client? Domestos has a two characters at the end of a line. A line feed and a carriage return. Unix has just the line feed. I wrote a win32/unix client server app recently and didn't have any problems with the conversion. I wouldn't use a chop instead of chomp here but I doubt the carriage return is a random event. I've tried to re-create the problem with the following code on NT and Solaris but I'm afraid it works fine for me?

Server code on a unix box
#!/usr/local/bin/perl use IO::Socket; print "Waiting...\n"; $socket = IO::Socket::INET->new(LocalPort => 4321, Proto => 'udp'); $socket->recv($text,128); chomp $text; print "Got this message: >${text}<\n"; close $socket;


And the client
#!/usr/local/bin/perl use IO::Socket; $x="my string ends here\n"; $sock = new IO::Socket::INET( PeerAddr => 'machine_name', PeerPort => 4321, Proto => 'udp'); $sock->send($x);


Produces;
Got this message: >my string ends here<

In my experience some ftp/udp/tcp clients leave the ^M on and some don't. If you have it check out Russ's node Removing ^M

In reply to RE: CHOMP VS. CHOP by Jonathan
in thread CHOMP VS. CHOP by radagast

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.