-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
25 lines (22 loc) · 817 Bytes
/
Server.java
File metadata and controls
25 lines (22 loc) · 817 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
package Lab2;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
// TODO code application logic here
try {
ServerSocket ss = new ServerSocket(3999);
System.out.println("Listening.....");
Socket s = ss.accept();
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
DataInputStream dis = new DataInputStream(s.getInputStream());
String data = dis.readUTF();
System.out.println("Reed: "+data);
dos.writeUTF(data);
ss.close();
}catch(IOException e) {e.printStackTrace();}
}
}