-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathServer.java
More file actions
32 lines (25 loc) · 771 Bytes
/
Server.java
File metadata and controls
32 lines (25 loc) · 771 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
import java.net.*;
import java.io.*;
public class Server
{
public static void main(String args[])throws Exception
{
ServerSocket ss=new ServerSocket(8080);
Socket s=ss.accept();
System.out.println("Online");
DataInputStream dataRead=new DataInputStream(s.getInputStream());
DataOutputStream dataWrite=new DataOutputStream(s.getOutputStream());
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
String str1="",str2="";
while(!str1.equals("bye"))
{
str1=dataRead.readUTF();
System.out.println("Client :"+str1);
str2=br.readLine();
dataWrite.writeUTF(str2);
dataWrite.flush();
}
dataRead.close();
s.close();
}
}