serv.c 1.21 KB
Newer Older
Kristin Wright's avatar
Kristin Wright committed
1
/* 
Mike Hibler's avatar
Mike Hibler committed
2
 * EMULAB-COPYRIGHT
Kristin Wright's avatar
Kristin Wright committed
3 4 5 6 7 8 9 10 11 12
 * Copyright (c) 2000 The University of Utah and the Flux Group.
 * All rights reserved.
 *
 * ---------------------------
 *
 * Filename: serv.c
 *   -- Author: Kristin Wright <kwright@cs.utah.edu> 
 *
 * ---------------------------
 *
Mike Hibler's avatar
Mike Hibler committed
13
 * $Id: serv.c,v 1.8 2004-06-17 18:17:01 mike Exp $
Kristin Wright's avatar
Kristin Wright committed
14 15 16 17 18 19 20 21 22 23 24 25 26
 */

#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;
27 28
	struct sockaddr 	name;
	int 			namelen=sizeof(name);	
Kristin Wright's avatar
Kristin Wright committed
29 30 31 32 33 34 35 36

	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);

37 38 39 40
	if(bind(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr))<0)
	{
		perror("bind");
	}
41 42
	//printf("The address I am listening on is: %s\n",inet_ntoa(servaddr.sin_addr));
	/*
43 44 45 46 47
	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));
48
	*/
Kristin Wright's avatar
Kristin Wright committed
49 50 51 52 53 54
	serv_listen(sockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr));
	
	/* We'll never get here */
	
	exit(0);
}