in reply to I need simple socket tutorial (or any other way to connect via UDP).

To get the server's response, recv.

The Perl Cookbook has good examples of using sockets.

After Compline,
Zaxo

  • Comment on Re: I need simple socket tutorial (or any other way to connect via UDP).

Replies are listed 'Best First'.
Re^2: I need simple socket tutorial (or any other way to connect via UDP).
by Cap'n Steve (Friar) on Aug 18, 2005 at 04:36 UTC
    As a side note, why is the recv() subroutine set up so strangely? Passing the variable that will hold what the function returns reminds me of PHP and its "forced references". Wouldn't this code be much more intuitive and Perlish?

    $reponse = $socket->recv($length, $flags);

    And for that matter, how is this even done? I would think you'd at least need the name of the variable to set it from another package. Isn't passing an uninitialized variable the same as passing an empty string? I'm all confused, perhaps someone could explain what I think are the relevant bits of recv() in IO::Socket:
    my $sock = $_[0]; ${*$sock}{'io_socket_peername'} = recv($sock, $_[1]='', $len, $flags);