in reply to Socket not accepting connection
Changes:
#!/usr/bin/perl -w use strict; use warnings; use IO::Socket::INET; my $sock = startListening(); close ($sock); sub startListening{ my $sock = new IO::Socket::INET( LocalPort => '8081',Proto => 'tcp +',Listen => '1', Reuse => '1') or die "ERROR: Could not create socket.\n$!"; my $new_sock = $sock->accept() or die "ERROR:Lost connection:"; print "Received incoming connection from " .$new_sock->peerhos +t () . ", remote port " . $new_sock->peerport() . "\n"; print $new_sock "Ave, Mundus!\n"; close $new_sock or warn "Could not close new sock:$!"; return $sock; }
All great truths begin as blasphemies.
― George Bernard Shaw, writer, Nobel laureate (1856-1950)
|
|---|