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);
In reply to IO::Socket vs IO::Socket::INET for simple webserver by corwin18
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |