Initial commit
This commit is contained in:
24
Problem 3.16/SocketClient.java
Normal file
24
Problem 3.16/SocketClient.java
Normal file
@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user