--- orig/src/SSF/OS/TCP/test/tcpServer.java
+++ mod/src/SSF/OS/TCP/test/tcpServer.java
@@ -39,6 +39,9 @@
   /** size of data request object from matching client */
   public int request_size;
 
+  /** data is sent in chunks */
+  public int chunk_size = 0;
+
   /** "listening" socket of this server */
   public tcpSocket lsd;
 
@@ -90,16 +93,16 @@
     Object[] obj;
     Continuation masterCont;
 
-    void serviceRequest(Continuation caller) {
-      masterCont = caller;
-      obj = new Object[1];
-      sd.read(obj, owner.request_size, new Continuation() {
-        public void success() {
-          nbytesRequest = ((Integer)obj[0]).intValue();
-          if(debug)
-            serverInfo("slave read(), request "+nbytesRequest+"B OK");
-          sd.write(nbytesRequest, new Continuation() {
+	Object[] payload={"payload"};
+
+	void main() {
+		  final int size = (nbytesRequest>chunk_size && chunk_size>0)?chunk_size:nbytesRequest;
+          sd.write(payload, size, new Continuation() {
             public void success() { 
+				nbytesRequest -= size;
+				System.out.println("wrote "+size+" "+nbytesRequest);
+				//Thread.dumpStack();
+				if (nbytesRequest <= 0) {
               // succeeded sending to client
               try {
                 //sd.close(masterCont);
@@ -118,13 +121,28 @@
               } catch (ProtocolException e) {
                 System.err.println(e);
               } 
+			  } else {
+				main();
+			  }
             }
             public void failure(int errno) { // failed writing
               if(debug)
                 serverInfo("slave write() "+nbytesRequest+"B failure");
               masterCont.failure(errno);
             }
-          });
+          }
+		  );
+	}
+
+    void serviceRequest(Continuation caller) {
+      masterCont = caller;
+      obj = new Object[1];
+      sd.read(obj, owner.request_size, new Continuation() {
+        public void success() {
+          nbytesRequest = ((Integer)obj[0]).intValue();
+          if(debug)
+            serverInfo("slave read(), request "+nbytesRequest+"B OK");
+		  main();
         }
         public void failure(int errno) { // failed reading clnt request
           if(debug)
@@ -184,6 +202,9 @@
     if((str = (String)cfg.findSingle("request_size")) != null)
       request_size = (new Integer(str)).intValue();
 
+    if((str = (String)cfg.findSingle("chunk_size")) != null)
+      chunk_size = (new Integer(str)).intValue();
+
     if((str = (String)cfg.findSingle("client_limit")) != null)
       client_limit = (new Integer(str)).intValue();
 

