Files
2019-03-17 23:28:35 +08:00

24 lines
694 B
Java

import java.net.*;
import java.io.*;
public class SocketClient {
public static void main(String[] args) {
try {
// make connection to server socket
Socket sock = new Socket("127.0.0.1", 6017);
InputStream in = sock.getInputStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
// get a qoute from the socket
String line;
while ( (line = bin.readLine()) != null)
System.out.println(line);
// close the socket connection
sock.close();
}
catch (IOException ioe) {
System.err.println(ioe);
}
}
}