Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RE: CHOMP VS. CHOP

by Jonathan (Curate)
on Aug 02, 2000 at 13:22 UTC ( [id://25687]=note: print w/replies, xml ) Need Help??


in reply to CHOMP VS. CHOP

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://25687]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found