- my ($s_ip,$s_port) = ('127.0.0.1', $listen_port);
- my $sin = sockaddr_in($s_port, inet_aton($s_ip))
- or die "** Failed packing $s_ip:$s_port\n";
- socket($waitmode_sock, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
- or die "** Unable to open socket $s_ip:$s_port: $!\n";
- setsockopt($waitmode_sock, SOL_SOCKET, SO_REUSEADDR, 1)
- or die "** Unable to setsockopt(SO_REUSEADDR): $!\n";
- bind($waitmode_sock, $sin)
- or die "** Unable to bind socket ($s_port): $!\n";
- listen($waitmode_sock, 5);