Non Blocking Single File HTTP Server - Online Code

Description

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.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.Iterator;
import java.net.*;

public class NonblockingSingleFileHTTPServer {

  private ByteBuffer contentBuffer;
  private int port = 80;

  pu
... (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.




Comments

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