-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathq1servercode.java
More file actions
29 lines (24 loc) · 819 Bytes
/
q1servercode.java
File metadata and controls
29 lines (24 loc) · 819 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
package javaPractical;
import java.net.*;
import java.io.*;
public class JyotiServer {
public static void main(String[] args) throws Exception{
ServerSocket ss=new ServerSocket(8080);
Socket s=ss.accept();
System.out.println("connection is stable now ");
DataInputStream dataRead=new DataInputStream(s.getInputStream());
DataOutputStream dataWrite=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("hello, jyoti")){
str=dataRead.readUTF();//reads whatever is sent by the client
System.out.println("Client says: "+str);
str2=br.readLine();
dataWrite.writeUTF(str2);
dataWrite.flush();
}
dataRead.close();
s.close();
ss.close();
}
}