-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient2.java
More file actions
37 lines (34 loc) · 1018 Bytes
/
Copy pathClient2.java
File metadata and controls
37 lines (34 loc) · 1018 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
31
32
33
34
35
36
37
import java.net.*;
import java.io.*;
import java.util.*;
class Client2{
public static void main(String args[])throws Exception{
int a;
Socket s=new Socket("localhost",6666);
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
Scanner sc=new Scanner(System.in);
System.out.println("1");
//String a=s.isConnected();
String str="",str2="";
while(s.isConnected()&&(!s.isClosed())){
System.out.println("2");
str=sc.next();
str2=din.readUTF();
do{
System.out.println("entered do while");
if(str2!=null) {a=1;System.out.println("value"+str2);}
else if(str!=null) a=0;
else a=2;
switch(a){
case 0:dout.writeUTF(str);
dout.flush();
break;
case 1:
System.out.println("Server says: "+str2);
break;
case 2:break;
}}while(str!=null || str2!=null ); }
dout.close();
s.close();
}}