25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 lines
409 B

  1. #!/usr/bin/env perl
  2. #
  3. # Just opens a socket and tries to connect() to it. rc = 1 on failure, 0 success
  4. #
  5. use Socket;
  6. local $where = $ARGV[0];
  7. local $port = $ARGV[1];
  8. socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname("tcp"))[2]);
  9. if(connect(SOCKET,sockaddr_in($port,inet_aton($where)))){
  10. print "connect($where, $port) succeeded\n";
  11. exit 0;
  12. }else{
  13. print "connect($where, $port) failed\n";
  14. exit 1;
  15. };