rendered paste bodydijkstra:~> diff -u myserver.c.orig myserver.c
--- myserver.c.orig 2006-12-27 21:43:35.000000000 +0200
+++ myserver.c 2006-12-27 21:53:17.000000000 +0200
@@ -28,6 +28,8 @@
int buflen;
+ printf("DEBUG: Writing %d bytes of data...\n", len);
+
buflen = write(fd, buf, len);
if ( buflen != len ) {
@@ -216,7 +218,7 @@
if ( buflen == 0 ) {
printf("Client from %s disconnected!\n", clientname);
- return; /* exit here */
+ break; /* Stop serving requests */
}
@@ -224,7 +226,7 @@
if ( (strncmp(buffer, "ls", 2) == 0 ) && (buflen==3 ) ) {
cmd_ls(fd);
- return; /* exit here */
+ continue; /* Skip to beginning of main loop */
} else if ( strncmp(buffer, "cd ", 3) == 0 ) {
@@ -248,24 +250,24 @@
/* printf("DEBUG: directoryname is %s\n", directoryname); */
cmd_cd(fd, directoryname);
- return; /* exit here */
+ continue; /* Skip to beginning of main loop */
} else if ( (strncmp(buffer, "quit", 4) == 0) && (buflen==5 ) ) {
printf("Client from %s has quit\n", clientname);
out(fd, "Disconnected!", 13);
- return; /* exit here */
+ continue; /* Skip to beginning of main loop */
} else if ( (strncmp(buffer, "get", 3) == 0) || (strncmp(buffer, "put", 3) == 0) ) {
printf("This command to implement...\n");
- return; /* exit here */
+ continue; /* Skip to beginning of main loop */
} else {
out(fd, "Unknown command: ", 18);
out(fd, buffer, buflen);
- return; /* exit here */
+ continue; /* Skip to beginning of main loop */
}
/* parse commands ends */