blob: 21c4abcb5375d3fd699889012ad443c887639c1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package org.simpleframework.http.socket;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
public class WebSocketTestClient {
public static void main(String[] list) throws Exception {
Socket socket = new Socket("localhost", 80);
OutputStream out = socket.getOutputStream();
byte[] request = ("GET / HTTP/1.0\r\n\r\n").getBytes("ISO-8859-1");
out.write(request);
InputStream in = socket.getInputStream();
byte[] chunk = new byte[1024];
int count = 0;
while((count = in.read(chunk)) != -1) {
Thread.sleep(1000);
System.err.write(chunk, 0, count);
}
}
}
|