Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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

by marcos (Scribe)
on May 02, 2000 at 15:03 UTC ( #9921=categorized answer: print w/replies, xml ) Need Help??

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

I use the <> operator to read data from a socket:
use strict; use IO::Socket; my $host = ''; 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;


Log In?

What's my password?
Create A New User
[marioroy]: Morning Discipulus. porting C code to Perl is an interesting problem for running parallel. I will try and the reason for attempting Perl code to match C 100%.
marto waves
[Discipulus]: hello marioroy! yes i need to start to write parallel, but not with this Pi code; it is yet melting my brain on it's own!

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2017-10-24 07:10 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (286 votes). Check out past polls.