DEV Community

Yuki Kimoto
Yuki Kimoto

Posted on

3 1

SPVM::IO::Socket::INET is available in experimental status.

SPVM::IO::Socket::INET is available in the experimental status.

  use IO::Socket::INET;

  my $host = "google.com";
  my $port = 80;
  my $io_socket = IO::Socket::INET->new({
    PeerAddr => $host,
    PeerPort => $port
  });

  my $send_buffer = "GET / HTTP/1.0\r\n\r\n";
  $socket->send($send_buffer);

  my $recv_buffer = (mutable string)new_string_len 100;
  while (1) {
    my $recv_length = $socket->recv($recv_buffer);

    if ($recv_length < 0) {
      die "Read error";
    }

    say Fn->substr($recv_buffer, 0, $recv_length);

    if ($recv_length < length $recv_buffer) {
      last;
    }
  }
Enter fullscreen mode Exit fullscreen mode

This module is a IO::Socket::INET porting to SPVM.

SPVM is approaching the goal of IoT. SPVM can access the Web via HTTP and create an executable file using spvmcc for devices.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay