BUU has asked for the wisdom of the Perl Monks concerning the following question:
sub q3msg { my ($host, $port, $timeout, $msg) = @_; my $iaddr = gethostbyname(hostname()); my $sin = sockaddr_in(0, $iaddr); socket(SOCK, PF_INET, SOCK_DGRAM, getprotobyname('udp')) or die "s +ocket: $!\n"; bind(SOCK, $sin) or die "bind: $!\n"; my $hisaddr = inet_aton($host) or die "unknown host \"$host\"\n"; my $srvaddr = sockaddr_in($port, $hisaddr); defined(send(SOCK, chr(255) x 4 . $msg, 0, $srvaddr)) or die "send +: $!\n"; my ($rin, $rout); $rin = ""; vec($rin, fileno(SOCK), 1) = 1; if (select($rout=$rin, undef, undef, $timeout)) { recv(SOCK, $_, 65507, 0) or die "recv: $!\n"; s/\033.//g; my @response = split /^/m; shift @response; return \@response; } else { return undef; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Translating Socket to IO::Socket;
by pg (Canon) on Jan 08, 2004 at 02:27 UTC | |
|
Re: Translating Socket to IO::Socket;
by perrin (Chancellor) on Jan 08, 2004 at 04:27 UTC | |
|
Re: Translating Socket to IO::Socket;
by pg (Canon) on Jan 08, 2004 at 04:48 UTC | |
|
Re: Translating Socket to IO::Socket;
by zentara (Cardinal) on Jan 08, 2004 at 17:50 UTC |