import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class MainClass {
public static void main(String[] args) throws IOException {
int port = 9000;
ServerSocket server = new ServerSocket(port);
while (true) {
Socket socket = server.accept();
Thread stuffer = new StuffThread(socket);
stuffer.start();
}
}
}
class StuffThread extends Thread {
private byte[] data = new byte[255];
private Socket socket;
public StuffThread(Socket socket) {
for (int i = 0; i < data.length; i++)
data[i] = (byte) i;
this.socket = socket;
}
public void run() {
try {
OutputStream out = new BufferedOutputStream(socket.getOutputStream());
while (!socket.isClosed()) {
out.write(data);
}
socket.close();
} catch (Exception e) {
}
}
}