r2220 - in alfs-POC: . src

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


Author: jhuntwork
Date: 2005-11-25 18:03:52 -0700 (Fri, 25 Nov 2005)
New Revision: 2220

Added:
   alfs-POC/src/
   alfs-POC/src/client.c
   alfs-POC/src/server.c
Removed:
   alfs-POC/client-server/
   alfs-POC/src/client.c
   alfs-POC/src/server.c
Log:
Moved 'client-server' dir to a simpler named dir

Copied: alfs-POC/src (from rev 2218, alfs-POC/client-server)

Deleted: alfs-POC/src/client.c
===================================================================
--- alfs-POC/client-server/client.c	2005-11-25 21:41:25 UTC (rev 2218)
+++ alfs-POC/src/client.c	2005-11-26 01:03:52 UTC (rev 2220)
@@ -1,58 +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;
-	char recvline [MAXLINE+1];
-	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*/
-	connect(sockfd, (SA *) &servaddr, sizeof(servaddr));
-
-	/* 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);
-}
-

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

Deleted: alfs-POC/src/server.c
===================================================================
--- alfs-POC/client-server/server.c	2005-11-25 21:41:25 UTC (rev 2218)
+++ alfs-POC/src/server.c	2005-11-26 01:03:52 UTC (rev 2220)
@@ -1,54 +0,0 @@
-#include <stdio.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);
-
-		/* fill buffer with data to send to client */		
-		snprintf(buff, sizeof(buff), "This is a test\r\n");
-
-		/* send buffer to client */
-		write(connfd, buff, strlen(buff));
-
-		/* close connection, restart while loop, goes back to sleep
-		  after accept	*/
-		close(connfd);
-	}
-}
-

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




More information about the alfs-log mailing list