Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
laziness, impatience, and hubris
 
PerlMonks  

IO::Socket vs IO::Socket::INET for simple webserver

by corwin18 (Initiate)
on Oct 18, 2011 at 20:26 UTC ( #932241=perlquestion: print w/ replies, xml ) Need Help??
corwin18 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to create a very simple webserver which can write to and read from a socket. I have been getting several different suggestions to use either IO::Socket or IO::Socket::INET. I don't know which would be better and why. Could someone please give me a quick explanation thanks!

This is what I have so far for my code, please any suggestions are very appreciated!

use IO::Socket::INET; my $socklist = new IO::Socket::INET (Listen =>1, LocalHOST =>'localhost', LocalPort => 6500, Proto => 'tcp', Reuse => 1); die "I couldn't create socket: $!\n" unless $socklist; my $sock_acpt = $socklist->accept(); while($sock_acpt){ print $_; } close($socklist); my $sockcli = new IO::Socket::INET ( PeerAddr => 'Chromium', PeerPort => '6500', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sockcli; print $sockcli "hello there!\n"; close($sockcli);

Comment on IO::Socket vs IO::Socket::INET for simple webserver
Download Code
Re: IO::Socket vs IO::Socket::INET for simple webserver
by ikegami (Pope) on Oct 18, 2011 at 22:33 UTC
Re: IO::Socket vs IO::Socket::INET for simple webserver
by Sewi (Friar) on Oct 19, 2011 at 05:35 UTC

      I am trying to build my own for a class assignment which is why I sent in the code. Thank you for your responses. Are there any suggestions for improving my code?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-04-18 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (466 votes), past polls