forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
30 lines (26 loc) · 869 Bytes
/
Copy pathClient.java
File metadata and controls
30 lines (26 loc) · 869 Bytes
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
26
27
28
29
30
//file: Client.java
import java.net.*;
import java.io.*;
public class Client {
public static void main( String argv[] ) {
try {
Socket server =
new Socket( argv[0], Integer.parseInt(argv[1]) );
ObjectOutputStream out =
new ObjectOutputStream( server.getOutputStream( ) );
ObjectInputStream in =
new ObjectInputStream( server.getInputStream( ) );
out.writeObject( new DateRequest( ) );
out.flush( );
System.out.println( in.readObject( ) );
out.writeObject( new MyCalculation( 2 ) );
out.flush( );
System.out.println( in.readObject( ) );
server.close( );
} catch ( IOException e ) {
System.out.println( "I/O error " + e ); // I/O error
} catch ( ClassNotFoundException e2 ) {
System.out.println( e2 ); // unknown type of response object
}
}
}