Non Blocking Single File HTTP Server - Online Code


Duplication is useful when you want to transmit the same data over multiple channels roughly in parallel. In this code the single file to serve is stored in one constant read only buffer every time a client connectsthe peogram makes the duplicate of this bufferjust for that channel,which is stored as the channels attachment.without duplicates,one client has to wait till the other finishes so the original buffer could be rewound.Duplicates ensble simultaneous buffer reuse.

Source Code

import java.nio.*;
import java.nio.channels.*;
import java.util.Iterator;

public class NonblockingSingleFileHTTPServer {

  private ByteBuffer contentBuffer;
  private int port = 80;

... (login or register to view full code)

To view full code, you must Login or Register, its FREE.

Hey, registering yourself just takes less than a minute and opens up a whole new GetGyan experience.


No comment yet. Be the first to post a comment.