rava2
home
documentation
examples
public class Main { public static void main(String[] args) { System.out.println("Starting on 8091"); ServerSocket server = new ServerSocket(8091); System.out.println("Waiting for connection..."); Socket client = server.accept(); System.out.println("Client connected"); var input = client.getInputStream(); System.out.println("Got input stream: " + input); var output = client.getOutputStream(); System.out.println("Got output stream: " + output); if (input == null) { System.out.println("Input is NULL!"); client.close(); return; } String req = input.readLine(); System.out.println("REQ: " + req); String response = "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nHello"; output.write(response); System.out.println("Response sent"); client.close(); System.out.println("Done"); } }
run program
ready