Skip to content

Instantly share code, notes, and snippets.

@mumumu
Created December 24, 2012 10:37
Show Gist options
  • Save mumumu/4368762 to your computer and use it in GitHub Desktop.
Save mumumu/4368762 to your computer and use it in GitHub Desktop.
this code gets "Bad arg length for Socket::pack_sockaddr_in" error. we can fix this error by changing 2nd parameter of pack_sockaddr_in function.
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::Socket;
use Data::Dumper;
my $socket = IO::Socket::INET->new(
Proto => 'tcp',
Type => SOCK_STREAM
) || die "creating socket: $!";
my $port = 80;
my $remote_addr = "www.google.com";
$remote_addr = pack_sockaddr_in( $port, $remote_addr );
connect($socket, $remote_addr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment