Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Anonymous Monk
on Apr 06, 2000 at 00:36 UTC ( [id://6966]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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

Originally posted as a Categorized Question.

  • Comment on How do I get started (reading data from a socket)

Replies are listed 'Best First'.
Re: How do I get started (reading data from a socket)
by marcos (Scribe) on May 02, 2000 at 15:03 UTC
    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
Re: How do I get started (reading data from a socket)
by Anonymous Monk on Jul 13, 2001 at 18:28 UTC
    Answer: I'am clear about u r context,but i would like to give my feedback on this: If u want to read data from a socket, better check the socket whether it is ready for reading (means has it got any data to read ????, then start reading, otherwise the read calls may turn out to be blocking calls) i beleive u have select() fun to check whether a socket is ready to receive,use it , confirm , start reading --------Fhani

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2024-04-19 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found