-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
32 lines (24 loc) · 871 Bytes
/
Server.java
File metadata and controls
32 lines (24 loc) · 871 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
package com.soc.chat;
import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args[])throws IOException{
ServerSocket ss1=new ServerSocket(3333);
Socket s2=ss1.accept();
DataInputStream din=new DataInputStream(s2.getInputStream());
DataOutputStream dout=new DataOutputStream(s2.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Server running");
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s2.close();
ss1.close();
}
}