r2221 - alfs-POC/src

jhuntwork at linuxfromscratch.org jhuntwork at linuxfromscratch.org
Fri Nov 25 17:09:17 PST 2005


Author: jhuntwork
Date: 2005-11-25 18:09:17 -0700 (Fri, 25 Nov 2005)
New Revision: 2221

Added:
   alfs-POC/src/alfs.c
   alfs-POC/src/alfsd.c
Removed:
   alfs-POC/src/client.c
   alfs-POC/src/server.c
Modified:
   alfs-POC/src/Makefile
Log:
Renamed the components and adjusted the Makefile to follow suit.

Modified: alfs-POC/src/Makefile
===================================================================
--- alfs-POC/src/Makefile	2005-11-26 01:03:52 UTC (rev 2220)
+++ alfs-POC/src/Makefile	2005-11-26 01:09:17 UTC (rev 2221)
@@ -1,10 +1,7 @@
-all: client server
+all: alfs alfsd
 
-client: client.c
-	gcc -W -Wall -Werror -pedantic -std=gnu99 -D_GNU_SOURCE client.c -o client
+alf%:
+	gcc -W -Wall -Werror -pedantic -std=gnu99 -D_GNU_SOURCE $@.c -o $@
 
-server: server.c
-	gcc -W -Wall -Werror -pedantic -std=gnu99 -D_GNU_SOURCE server.c -o server
-
 clean:
-	rm client server
+	rm alfs alfsd

Copied: alfs-POC/src/alfs.c (from rev 2220, alfs-POC/src/client.c)

Copied: alfs-POC/src/alfsd.c (from rev 2220, alfs-POC/src/server.c)

Deleted: alfs-POC/src/client.c
===================================================================
--- alfs-POC/src/client.c	2005-11-26 01:03:52 UTC (rev 2220)
+++ alfs-POC/src/client.c	2005-11-26 01:09:17 UTC (rev 2221)
@@ -1,73 +0,0 @@
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-
-int
-main (int argc, char **argv)
-{
-
-	#define MAXLINE 4096 /* used for buffer size */
-	#define SA struct sockaddr /* just a shortcut, saves typing
-				      later in the connect() function
-				      and prevents that line from wrapping
-				   */
-	
-	int sockfd, n, len;
-	char recvline [MAXLINE+1];
-	char input[81];
-	struct sockaddr_in servaddr;
-	
-	if (argc != 2) {
-		printf("usage: %s IPaddress\n", argv[0]);
-		exit(1);
-	}
-
-	/* setup socked descriptor */
-	sockfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	/* set structure to zero */
-	bzero(&servaddr, sizeof(servaddr));
-
-	/* set to IPv4 */
-	servaddr.sin_family = AF_INET;
-
-	/* Use port 1234 */
-	servaddr.sin_port = htons(1234);
-
-	/* convert provided IP address into numeric */
-	inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
-
-	/* connect to socket descriptor to port set above*/
-	if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) == -1)
-	{
-		printf("Connection failed!\n");
-		exit(1);
-	} else {
-		printf("Connected to %s\n", argv[1]);
-	}
-
-	/* Read input from the user to send to the server */
-	printf("Enter a command to send to the server:\n");
-	scanf("%s", input);
-	len = strlen(input);
-	printf("You entered: %s\n", input);
-
-	/* Send the input to the server */
-	send(sockfd, input, len, 0);
-
-	/* read data from server */	
-	n = read(sockfd, recvline, MAXLINE);
-	recvline[n] = 0;
-
-	if (fputs(recvline, stdout) == EOF)
-		printf("fputs error\n");
-
-	if (n < 0)
-		printf("read error\n");
-	
-	exit(0);
-}
-

Deleted: alfs-POC/src/server.c
===================================================================
--- alfs-POC/src/server.c	2005-11-26 01:03:52 UTC (rev 2220)
+++ alfs-POC/src/server.c	2005-11-26 01:09:17 UTC (rev 2221)
@@ -1,61 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <netinet/in.h>
-
-int
-main ()
-{
-
-	#define MAXLINE 4096
-	#define LISTENQ 5
-	#define SA struct sockaddr
-
-	int listenfd, connfd;
-	struct sockaddr_in servaddr;
-	char buff[MAXLINE];
-	
-	/* setup socket descriptor */
-	listenfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	/* set structure to zero */	
-	bzero(&servaddr, sizeof(servaddr));
-
-	/* set to IPv4 */
-	servaddr.sin_family = AF_INET;
-
-	/* listen on any IP address port 1234 */
-	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
-	servaddr.sin_port = htons(1234);
-
-	/* bind to socket and listen for incoming requests */	
-	bind(listenfd, (SA *) &servaddr, sizeof(servaddr));
-	listen(listenfd, LISTENQ);
-
-	/* endless loop. Service one client at a time, then go back
-	   to listening */	
-	for ( ; ; ) {
-		/* process goes to sleep after 'accept' until a client
-		   connection arrives and is accepted after TCP's
-		   three-way handshake*/
-		connfd = accept(listenfd, (SA *) NULL, NULL);
-
-		recv(connfd, buff, sizeof(buff), 0);
-
-		printf("SERVER: Executing \"%s\"\n", buff);
-
-		system(buff);
-
-		/* fill buffer with data to send to client */		
-		snprintf(buff, sizeof(buff), "CLIENT: Command successful!\r\n");
-
-		/* send buffer to client */
-		write(connfd, buff, strlen(buff));
-
-		/* close connection, restart while loop, goes back to sleep
-		  after accept	*/
-		close(connfd);
-	}
-}
-




More information about the alfs-log mailing list