From owner-freebsd-questions@FreeBSD.ORG Sun Jan 14 15:24:54 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5854216A407 for ; Sun, 14 Jan 2007 15:24:54 +0000 (UTC) (envelope-from pietro.cerutti@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by mx1.freebsd.org (Postfix) with ESMTP id E7C8513C469 for ; Sun, 14 Jan 2007 15:24:53 +0000 (UTC) (envelope-from pietro.cerutti@gmail.com) Received: by ug-out-1314.google.com with SMTP id o2so1023242uge for ; Sun, 14 Jan 2007 07:24:52 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=RutF8rJxGZTArm3yJ9DgAbJ0hLTbkHLIEgAv1tVqOAR4aJp7UMybP4pswF2F3O9hbx8rE/+6TGIKfchfsGncounRegoaOqKj9iAr0I0npi9HIeLgpDDxQKuQ8iPhdfkrDYQWAKnnmN0O65ilsIEr5O66RBH0vj4z3c9DaxHNno8= Received: by 10.66.242.20 with SMTP id p20mr3969940ugh.1168788292576; Sun, 14 Jan 2007 07:24:52 -0800 (PST) Received: by 10.67.23.8 with HTTP; Sun, 14 Jan 2007 07:24:51 -0800 (PST) Message-ID: Date: Sun, 14 Jan 2007 16:24:51 +0100 From: "Pietro Cerutti" To: "Grant Peel" In-Reply-To: <008f01c737e9$c5518470$6501a8c0@GRANT> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <007e01c737d7$20573170$6501a8c0@GRANT> <008f01c737e9$c5518470$6501a8c0@GRANT> Cc: freebsd-questions@freebsd.org Subject: Re: Identifying a Remote Machine. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jan 2007 15:24:54 -0000 On 1/14/07, Grant Peel wrote: > ACtually no, > > Sory if the question was vauge, > > What I am looking to do is to create a tool that will identify what MACHINE > (not domain) an ip is being used on. Check out this: #include #include #include #include #include #include #include #define MAX_BUFF 128 #define MAX_NAME 128 int main(int argc, char **argv) { char buf[MAX_BUFF], name[MAX_NAME]; int recv, sock, addrlen; struct sockaddr_in addr, from; if(argc != 3) { fprintf(stderr, "usage: %s ip port\n", argv[0]); return(1); } addrlen = sizeof(struct sockaddr); /* get hostname */ bzero(&name, MAX_NAME); if(gethostname(name, MAX_NAME) == -1) { perror("gethostname"); return(1); } /* create socket */ if((sock = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { perror("socket"); return(1); } /* create addres */ bzero(&addr, addrlen); addr.sin_family = AF_INET; addr.sin_port = htons((int)strtol(argv[2], (char **)NULL, 10)); if(inet_aton(argv[1], addr.sin_addr) == 0) { perror("inet_aton"); return(1); } /* bind */ if(bind(sock, (struct sockaddr *)&addr, addrlen) == -1) { perror("bind"); return(1); } /* loop infinitely */ for(;;) { /* receive */ if((recv = recvfrom(sock, buf, MAX_BUFF -1, 0, (struct sockaddr *)&from, &addrlen)) == -1) { perror("recvfrom"); continue; } buf[recv] = '\0'; /* send hostname */ if(sendto(sock, name, MAX_NAME, 0, (struct sockaddr *)&from, sizeof(struct sockaddr)) == -1) { perror("sendto"); continue; } } return(0); } > > -Grant > > ----- Original Message ----- > From: "Pietro Cerutti" > To: "Grant Peel" > Cc: > Sent: Sunday, January 14, 2007 9:21 AM > Subject: Re: Identifying a Remote Machine. > > > > On 1/14/07, Grant Peel wrote: > >> Hi all, > > Hello, > > > >> The only reply I need from the server is the hostname. That will tell ne > >> that the IP is live and what machine its on. > > > > Wouldn't a ping be enough if you just need to know whether the machine is > > on? > > > >> > >> -Grant > > > > > > -- > > Pietro Cerutti > > ICQ: 117293691 > > PGP: 0x9571F78E > > > > - ASCII Ribbon Campaign - > > against HTML e-mail and > > proprietary attachments > > www.asciiribbon.org > > > > > > > -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org