Changes to nlsrc.c and nlsr.c to use correct port.
Add check in nlsrc.c to prevent a segmentation fault if user supplied wrong syntax.
diff --git a/nlsr.c b/nlsr.c
index 7846a1d..bd2ac39 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -755,13 +755,14 @@
 			}			
 			else if(fd == nlsr->nlsr_api_server_sock_fd)
 			{
+				printf("Setting up socket....\n");
 				client_len = sizeof(client_address);
 				client_sockfd = accept(nlsr->nlsr_api_server_sock_fd,(struct sockaddr *)&client_address, &client_len);
 				FD_SET(client_sockfd, &nlsr->readfds);
 			}
 			else
 			{   
-					
+				printf("Else...\n");		
 				ioctl(fd, FIONREAD, &nread);
 				if(nread == 0) 
 				{
@@ -771,7 +772,7 @@
 				else 
 				{
 					recv(fd, recv_buffer, 1024, 0);
-					printf("Received Data from NLSR API cleint: %s \n",recv_buffer);
+					printf("Test Received Data from NLSR API cleint: %s \n",recv_buffer);
 					char *msg=process_api_client_command(recv_buffer);
 					send(fd, msg, strlen(msg),0);
 					free(msg);
@@ -863,11 +864,13 @@
        	}
 
 	server_address.sin_family = AF_INET;
-	server_address.sin_addr.s_addr = inet_addr("127.0.0.1");
-	server_address.sin_port = nlsr->api_port;
+	//server_address.sin_addr.s_addr = inet_addr("127.0.0.1");
+	server_address.sin_addr.s_addr = INADDR_ANY;
+	server_address.sin_port = htons(nlsr->api_port);
 
 	server_len = sizeof(server_address);
 	bind(server_sockfd, (struct sockaddr *)&server_address, server_len);
+	//printf("port number %d\n", ntohs(server_address.sin_port));
 	listen(server_sockfd, 100);
 	FD_ZERO(&nlsr->readfds);
 	FD_SET(server_sockfd, &nlsr->readfds);
diff --git a/nlsrc.c b/nlsrc.c
index 44ce2ad..5e35b8c 100755
--- a/nlsrc.c
+++ b/nlsrc.c
@@ -22,12 +22,15 @@
 usage(char *progname)
 {
     printf("Usage: %s [OPTIONS...]\n\
-	NLSR Api client....\n\
+	NLSR API client....\n\
 	nlsrc -s server_ip -p server_port add|del name|neighbor name_prefix [faceX] \n\
-	add/del, -- adding/deleting operation\n\
-	name/neighbor, -- Operation for name/neighbor\n\
-	name_name, -- Name prefix for name/neighbor\n\
-	faceX, -- Face Id for neighbor if third argument is neighbor\n", progname);
+	option -- description\n\n\
+	add|del -- specify whether you want to add or delete.\n\
+	name|neighbor -- specify whether you are adding a name or a neighbor.\n\
+	name_prefix -- name of the prefix for the name|neighbor.\n\
+	faceX -- face ID for neighbor if the third argument is neighbor.\n\n\
+	Examples:\n\
+	1) nlsrc -s 127.0.0.1 -p 9696 add name /ndn/memphis.edu/test \n", progname);
 
     exit(1);
 }
@@ -41,12 +44,16 @@
 	int byteSend;
 	char *server_address, *server_port;	
 
-	int command_len=0;
+	int command_len = 0;
 	int i;
 
-	if (argc < 8 )
+	if (argc < 8)
 		usage(argv[0]);
-	if ( strcmp(argv[6],"neighbor") == 0 && argc <9 )
+
+	if (strcmp(argv[6], "neighbor") == 0 && argc < 9)
+		usage(argv[0]);
+
+	if (strcmp(argv[6], "name") != 0 && strcmp(argv[6], "neighbor") != 0)
 		usage(argv[0]);
 
 	while ((result = getopt_long(argc, argv, "s:p:", longopts, 0)) != -1) 
@@ -66,14 +73,17 @@
 	char recv_buffer[1024];
 	bzero(recv_buffer,1024);
 
-	for(i=5;i<argc;i++)
-		command_len+=(strlen(argv[i])+1);
-	char *command=malloc(command_len);
-	memset(command,command_len+1,0);
-	for(i=5;i<argc;i++)
+	for(i = 5; i < argc; i++)
+		command_len += (strlen(argv[i]) + 1);
+
+	char *command = malloc(command_len);
+	memset(command, 0, command_len + 1);
+
+	for(i = 5; i < argc; i++)
 	{
-		memcpy(command+strlen(command),argv[i],strlen(argv[i]));
-		if ( i < argc-1 )
+		memcpy(command+strlen(command), argv[i], strlen(argv[i]));
+		
+		if (i < argc - 1)
 			memcpy(command+strlen(command)," ",1);	
 	}
 
@@ -82,20 +92,25 @@
 	//strcpy(address.sun_path, "/tmp/nlsr_api_server_socket");
 	address.sin_family = AF_INET;
 	address.sin_addr.s_addr = inet_addr(server_address);
-	address.sin_port = atoi(server_port);
+	address.sin_port = htons(atoi(server_port));
 
 	len = sizeof(address);
 	result = connect(sockfd, (struct sockaddr *)&address, len);
+	
 	if(result == -1) 
 	{
 		perror("oops nlsrc ");
 		exit(1);
 	}
+
 	printf("Command to send: %s \n",command);
 	byteSend=send(sockfd, command, strlen(command),0);
+
 	recv(sockfd, recv_buffer, 1024, 0);
 	printf("%s\n",recv_buffer);
+
 	free(command);
 	close(sockfd);
-	exit(0);
+
+	return 0;
 }