http server

package net.datafans.exercise.rockmq.TestJMS;

import java.io.*;

import java.net.*;

public class ServerDemo {

public static void main(String args[]) throws IOException {

ServerSocket ss = new ServerSocket(12345);//端口号12345

while(true) {

Socket socket = ss.accept();

OutputStream out = socket.getOutputStream();

BufferedReader br = new BufferedReader(new FileReader("/Users/apple/Documents/demo/TestJMS/1.html"));

                        out.write("HTTP/1.0 200 \n".getBytes()); 

                        out.write("Content-Type: text/html\n".getBytes()); 

                        out.write("\n".getBytes());

String line=null;

while((line = br.readLine()) != null) {

out.write(line.getBytes());

}

socket.close();

br.close();

out.close();

}

}

 

 

python -m SimpleHTTPServer

sudo nc -kl 80

你可能感兴趣的:(server)