serv.c 1.68 KB
Newer Older
Kristin Wright's avatar
Kristin Wright committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* 
 * Copyright (c) 2000 The University of Utah and the Flux Group.
 * All rights reserved.
 *
 * Permission to use, copy, modify and distribute this software is hereby
 * granted provided that (1) source code retains these copyright, permission,
 * and disclaimer notices, and (2) redistributions including binaries
 * reproduce the notices in supporting documentation.
 *
 * THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * ---------------------------
 *
 * Filename: serv.c
 *   -- Author: Kristin Wright <kwright@cs.utah.edu> 
 *
 * ---------------------------
 *
21
 * $Id: serv.c,v 1.7 2001-08-04 22:58:30 ikumar Exp $
Kristin Wright's avatar
Kristin Wright committed
22 23 24 25 26 27 28 29 30 31 32 33 34
 */

#include "discvr.h"
#include "packet.h"

char hostname[MAX_HOSTNAME];
topd_inqid_t inqid_current;

int
main(int argc, char **argv)
{
	int			sockfd;
	struct sockaddr_in	servaddr, cliaddr;
35 36
	struct sockaddr 	name;
	int 			namelen=sizeof(name);	
Kristin Wright's avatar
Kristin Wright committed
37 38 39 40 41 42 43 44

	sockfd = socket(AF_INET, SOCK_DGRAM, 0);

	bzero(&servaddr, sizeof(servaddr));
	servaddr.sin_family      = AF_INET;
	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
	servaddr.sin_port        = htons(SERV_PORT);

45 46 47 48
	if(bind(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr))<0)
	{
		perror("bind");
	}
49 50
	//printf("The address I am listening on is: %s\n",inet_ntoa(servaddr.sin_addr));
	/*
51 52 53 54 55
	if(getsockname(sockfd, (struct sockaddr *)&name, &namelen)<0)
	{
		perror("getsockname\n");
	}
	printf("No I am listening on: \"%s\"\n",sock_ntop(&name,name.sa_len));
56
	*/
Kristin Wright's avatar
Kristin Wright committed
57 58 59 60 61 62
	serv_listen(sockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr));
	
	/* We'll never get here */
	
	exit(0);
}