mirror of
https://github.com/corda/corda.git
synced 2025-01-17 10:20:02 +00:00
make Sockets test Java6-compilable, make it more generic, and move it to 'extra'
This commit is contained in:
parent
45ee25f68c
commit
c3bbe555be
@ -1,3 +1,5 @@
|
|||||||
|
package extra;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,11 +17,12 @@ public class Sockets {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws UnknownHostException,
|
public static void main(String[] args) throws UnknownHostException,
|
||||||
IOException {
|
IOException {
|
||||||
System.out.print("Requesting...\n");
|
System.out.print("Requesting... " + args[0] + "\n");
|
||||||
try (Socket sock = new Socket("www.google.com", 80)) {
|
Socket sock = new Socket(args[0], 80);
|
||||||
|
try {
|
||||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
|
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
|
||||||
String request = "GET /?gws_rd=cr HTTP/1.1\r\n"
|
String request = "GET /?gws_rd=cr HTTP/1.1\r\n"
|
||||||
+ "Host: www.google.com\r\n" + "Accept: */*\r\n"
|
+ "Host: " + args[0] + "\r\n" + "Accept: */*\r\n"
|
||||||
+ "User-Agent: Java\r\n" + "Connection: close\r\n" + "\r\n";
|
+ "User-Agent: Java\r\n" + "Connection: close\r\n" + "\r\n";
|
||||||
bw.write(request);
|
bw.write(request);
|
||||||
bw.flush();
|
bw.flush();
|
||||||
@ -30,6 +33,7 @@ public class Sockets {
|
|||||||
System.out.println(read);
|
System.out.println(read);
|
||||||
}
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
|
} finally {
|
||||||
sock.close();
|
sock.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user