-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc1.java
More file actions
35 lines (33 loc) · 786 Bytes
/
Copy pathc1.java
File metadata and controls
35 lines (33 loc) · 786 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
package socketp1;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
public class c1
{
public static void main(String args[])
{
try
{
Socket s=new Socket("localhost",4999);
DataInputStream in=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream(s.getOutputStream());
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
while(true)
{ System.out.print("->");
String se=bf.readLine();
out.writeUTF(se);
if(se.equalsIgnoreCase("bye"))
break;
String re=in.readUTF();
System.out.println("server:"+re);
}
s.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}