Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Answer: How do I get started (reading data from a socket)

( #9921=categorized answer: print w/ replies, xml ) Need Help??

Q&A > network programming > How do I get started (reading data from a socket) contributed by marcos

I use the <> operator to read data from a socket:
use strict; use IO::Socket; my $host = 'myhost.mysite.org'; my $port = 7530; my $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => $port, Proto => 'tcp'); die "cannot open socket" unless ($sock); #send a command to the server my $cmd = "MYGET\n"; print $sock $cmd; # print server response while (<$sock>) { print; } close $sock;

marcos

Comment on Answer: How do I get started (reading data from a socket)
Download Code
Replies are listed 'Oldest First'.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (15)
As of 2015-07-07 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (91 votes), past polls