From 45340ebd2dabafe737cd533835af2a73d5fc3816 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Sat, 24 Jun 2000 23:09:44 +0000 Subject: [PATCH] don't call gethostbyname() with dotted quad argument; don't hardcode PF_INET and SOCK_STREAM; improve error reporting; indent by 8 spaces --- bin/tests/system/testsock.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/tests/system/testsock.pl b/bin/tests/system/testsock.pl index 64100ac71e..fa2af94dd6 100644 --- a/bin/tests/system/testsock.pl +++ b/bin/tests/system/testsock.pl @@ -15,16 +15,18 @@ # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. -# $Id: testsock.pl,v 1.2 2000/06/22 21:51:31 tale Exp $ +# $Id: testsock.pl,v 1.3 2000/06/24 23:09:44 gson Exp $ # Test whether the interfaces on 10.53.0.* are up. +require 5.001; + +use Socket; for ($id = 1 ; $id < 6 ; $id++) { - $sockaddr= 'S n a4 x8'; - ($name,$aliases,$type,$len,$thisaddr)=gethostbyname("10.53.0.$id"); - $this=pack($sockaddr,2,0,$thisaddr); - - socket(IRCSOCK,2,1,0) || die $!; - bind(IRCSOCK,$this) || die $!; + $sa = pack_sockaddr_in(0, pack("C4", 10, 53, 0, $id)); + socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp")) + or die "$0: socket: $!\n"; + bind(SOCK, $sa) + or die "$0: bind: $!\n"; }