
use IO::Socket;  # note:  not enough to have "use Socket"

package DSMUtils;

# subroutine to set up socket to server 

sub DSMCheckIn {
   # turn buffering off
   $| = 1;
   my $SrvrIP  = $ARGV[0];  # name of the server
   my $Port = $ARGV[1];
   my $SvrSkt = new IO::Socket::INET (PeerAddr=>$SrvrIP,
                                PeerPort=>$Port,
                                Proto=>'tcp');
   print $SvrSkt "checkin 0 0\n";
   my $Response = <$SvrSkt>;
   ($NumNodes,$MyNode) = split(" ",$Response);
   return ($SvrSkt,$NumNodes,$MyNode);
}

sub DSMCloseSocket {
   my $SvrSkt = shift;
   print $SvrSkt "close 0 0\n";
   close $SvrSkt;
}

1;  # needed due to quirk in Perl

